# Quansheng UV-K5 driver (c) 2023 Jacek Lipkowski <sq5bpf@lipkowski.org>
# Modified for Full Chinese Firmware by hank9999
#
# based on template.py Copyright 2012 Dan Smith <dsmith@danplanet.com>
#
#
# This is a preliminary version of a driver for the UV-K5
# It is based on my reverse engineering effort described here:
# https://github.com/sq5bpf/uvk5-reverse-engineering
#
# Warning: this driver is experimental, it may brick your radio,
# eat your lunch and mess up your configuration.
#
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import struct
import logging

from chirp import chirp_common, directory, bitwise, memmap, errors, util
from chirp.errors import InvalidValueError
from chirp.settings import RadioSetting, RadioSettingGroup, \
      RadioSettingValueBoolean, RadioSettingValueList, \
      RadioSettingValueInteger, RadioSettingValueString, \
      RadioSettings, RadioSettingValue

LOG = logging.getLogger(__name__)

# Show the obfuscated version of commands. Not needed normally, but
# might be useful for someone who is debugging a similar radio
DEBUG_SHOW_OBFUSCATED_COMMANDS = False

# Show the memory being written/received. Not needed normally, because
# this is the same information as in the packet hexdumps, but
# might be useful for someone debugging some obscure memory issue
DEBUG_SHOW_MEMORY_ACTIONS = False

MEM_FORMAT = """
#seekto 0x0000;
struct {
  ul32 freq;
  ul32 offset;
  u8 rxcode;
  u8 txcode;

  u8 unknown1:2,
  txcodeflag:2,
  unknown2:2,
  rxcodeflag:2;

  //u8 flags1;
  u8 flags1_unknown7:1,
  flags1_unknown6:1,
  flags1_unknown5:1,
  enable_am:1,
  flags1_unknown3:1,
  is_in_scanlist:1,
  shift:2;

  //u8 flags2;
  u8 flags2_unknown7:1,
  flags2_unknown6:1,
  flags2_unknown5:1,
  bclo:1,
  txpower:2,
  bandwidth:1,
  freq_reverse:1;

  //u8 dtmf_flags;
  u8 dtmf_flags_unknown7:1,
  dtmf_flags_unknown6:1,
  dtmf_flags_unknown5:1,
  dtmf_flags_unknown4:1,
  dtmf_flags_unknown3:1,
  dtmf_pttid:2,
  dtmf_decode:1;


  u8 step;
  u8 scrambler;
} channel[214];

#seekto 0xd60;
struct {
u8 is_scanlist1:1,
is_scanlist2:1,
unknown1:1,
unknown2:1,
is_free:1,
band:3;
} channel_attributes[200];

#seekto 0xe40;
ul16 fmfreq[20];

#seekto 0xe70;
u8 call_channel;
u8 squelch;
u8 max_talk_time;
u8 noaa_autoscan;
u8 key_lock;
u8 vox_switch;
u8 vox_level;
u8 mic_gain;
u8 unknown3;
u8 channel_display_mode;
u8 crossband;
u8 battery_save;
u8 dual_watch;
u8 backlight_auto_mode;
u8 tail_note_elimination;
u8 vfo_open;

#seekto 0xe90;
u8 beep_control;
u8 key1_shortpress_action;
u8 key1_longpress_action;
u8 key2_shortpress_action;
u8 key2_longpress_action;
u8 scan_resume_mode;
u8 auto_keypad_lock;
u8 power_on_dispmode;
u8 password[4];

#seekto 0xea0;
u8 keypad_tone;
u8 language;

#seekto 0xea8;
u8 alarm_mode;
u8 reminding_of_end_talk;
u8 repeater_tail_elimination;

#seekto 0xeb0;
char logo_line1[16];
char logo_line2[16];

#seekto 0xed0;
struct {
u8 side_tone;
char separate_code;
char group_call_code;
u8 decode_response;
u8 auto_reset_time;
u8 preload_time;
u8 first_code_persist_time;
u8 hash_persist_time;
u8 code_persist_time;
u8 code_interval_time;
u8 permit_remote_kill;
} dtmf_settings;

#seekto 0xee0;
struct {
char dtmf_local_code[3];
char unused1[5];
char kill_code[5];
char unused2[3];
char revive_code[5];
char unused3[3];
char dtmf_up_code[16];
char dtmf_down_code[16];
} dtmf_settings_numbers;

#seekto 0xf18;
u8 scanlist_default;
u8 scanlist1_priority_scan;
u8 scanlist1_priority_ch1;
u8 scanlist1_priority_ch2;
u8 scanlist2_priority_scan;
u8 scanlist2_priority_ch1;
u8 scanlist2_priority_ch2;
u8 scanlist_unknown_0xff;


#seekto 0xf40;
struct {
u8 flock;
u8 tx350;
u8 killed;
u8 tx200;
u8 tx500;
u8 en350;
u8 enscramble;
} lock;

#seekto 0xf50;
struct {
char name[16];
} channelname[200];

#seekto 0x1c00;
struct {
char name[8];
char number[3];
char unused_00[5];
} dtmfcontact[16];

#seekto 0x1fff;
u8 mdc_num;

#seekto 0x1d00;
struct {
    u8 id[2];
    char name[14];
} mdccontact1[22];

#seekto 0x1ed0;
struct {
struct {
    u8 start;
    u8 mid;
    u8 end;
} low;
struct {
    u8 start;
    u8 mid;
    u8 end;
} medium;
struct {
    u8 start;
    u8 mid;
    u8 end;
} high;
u8 unused_00[7];
} perbandpowersettings[7];

#seekto 0x1f40;
ul16 battery_level[6];
"""
# bits that we will save from the channel structure (mostly unknown)
SAVE_MASK_0A = 0b11001100
SAVE_MASK_0B = 0b11101100
SAVE_MASK_0C = 0b11100000
SAVE_MASK_0D = 0b11111000
SAVE_MASK_0E = 0b11110001
SAVE_MASK_0F = 0b11110000

# flags1
FLAGS1_OFFSET_NONE = 0b00
FLAGS1_OFFSET_MINUS = 0b10
FLAGS1_OFFSET_PLUS = 0b01

POWER_HIGH = 0b10
POWER_MEDIUM = 0b01
POWER_LOW = 0b00

# dtmf_flags
PTTID_LIST = ["off", "BOT", "EOT", "BOTH"]

# power
UVK5_POWER_LEVELS = [chirp_common.PowerLevel("Low",  watts=1.50),
                     chirp_common.PowerLevel("Med",  watts=3.00),
                     chirp_common.PowerLevel("High", watts=5.00),
                     ]

# scrambler
SCRAMBLER_LIST = ["off", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10"]

# channel display mode
CHANNELDISP_LIST = ["Frequency", "Channel No", "Channel Name"]
# battery save
BATSAVE_LIST = ["OFF", "1:1", "1:2", "1:3", "1:4"]

# Backlight auto mode
BACKLIGHT_LIST = ["Off", "1s", "2s", "3s", "4s", "5s"]

# Crossband receiving/transmitting
CROSSBAND_LIST = ["Off", "Band A", "Band B"]
DUALWATCH_LIST = CROSSBAND_LIST

# steps
STEPS = [2.5, 5.0, 6.25, 10.0, 12.5, 25.0, 8.33]

# ctcss/dcs codes
TMODES = ["", "Tone", "DTCS", "DTCS"]
TONE_NONE = 0
TONE_CTCSS = 1
TONE_DCS = 2
TONE_RDCS = 3


CTCSS_TONES = [
    67.0, 69.3, 71.9, 74.4, 77.0, 79.7, 82.5, 85.4,
    88.5, 91.5, 94.8, 97.4, 100.0, 103.5, 107.2, 110.9,
    114.8, 118.8, 123.0, 127.3, 131.8, 136.5, 141.3, 146.2,
    151.4, 156.7, 159.8, 162.2, 165.5, 167.9, 171.3, 173.8,
    177.3, 179.9, 183.5, 186.2, 189.9, 192.8, 196.6, 199.5,
    203.5, 206.5, 210.7, 218.1, 225.7, 229.1, 233.6, 241.8,
    250.3, 254.1
]

# lifted from ft4.py
DTCS_CODES = [
    23,  25,  26,  31,  32,  36,  43,  47,  51,  53,  54,
    65,  71,  72,  73,  74,  114, 115, 116, 122, 125, 131,
    132, 134, 143, 145, 152, 155, 156, 162, 165, 172, 174,
    205, 212, 223, 225, 226, 243, 244, 245, 246, 251, 252,
    255, 261, 263, 265, 266, 271, 274, 306, 311, 315, 325,
    331, 332, 343, 346, 351, 356, 364, 365, 371, 411, 412,
    413, 423, 431, 432, 445, 446, 452, 454, 455, 462, 464,
    465, 466, 503, 506, 516, 523, 526, 532, 546, 565, 606,
    612, 624, 627, 631, 632, 654, 662, 664, 703, 712, 723,
    731, 732, 734, 743, 754
]

FLOCK_LIST = ["Off", "FCC", "CE", "GB", "430", "438"]

SCANRESUME_LIST = ["TO: Resume after 5 seconds",
                   "CO: Resume after signal disappears",
                   "SE: Stop scanning after receiving a signal"]

WELCOME_LIST = ["Full Screen", "Welcome Info", "Voltage"]
KEYPADTONE_LIST = ["Off", "Chinese", "English"]
LANGUAGE_LIST = ["Chinese", "English"]
ALARMMODE_LIST = ["SITE", "TONE"]
REMENDOFTALK_LIST = ["Off", "ROGER", "MDC"]
RTE_LIST = ["Off", "100ms", "200ms", "300ms", "400ms",
            "500ms", "600ms", "700ms", "800ms", "900ms"]

MEM_SIZE = 0x2000  # size of all memory
PROG_SIZE = 0x1fff  # size of the memory that we will write
MEM_BLOCK = 0x80  # largest block of memory that we can reliably write

# fm radio supported frequencies
FMMIN = 76.0
FMMAX = 108.0

# bands supported by the UV-K5
BANDS = {
        0: [50.0, 76.0],
        1: [108.0, 135.9999],
        2: [136.0, 199.9990],
        3: [200.0, 299.9999],
        4: [350.0, 399.9999],
        5: [400.0, 469.9999],
        6: [470.0, 600.0]
        }

# for radios with modified firmware:
BANDS_NOLIMITS = {
        0: [18.0, 76.0],
        1: [108.0, 135.9999],
        2: [136.0, 199.9990],
        3: [200.0, 299.9999],
        4: [350.0, 399.9999],
        5: [400.0, 469.9999],
        6: [470.0, 1300.0]
        }

SPECIALS = {
        "F1(50M-76M)A": 200,
        "F1(50M-76M)B": 201,
        "F2(108M-136M)A": 202,
        "F2(108M-136M)B": 203,
        "F3(136M-174M)A": 204,
        "F3(136M-174M)B": 205,
        "F4(174M-350M)A": 206,
        "F4(174M-350M)B": 207,
        "F5(350M-400M)A": 208,
        "F5(350M-400M)B": 209,
        "F6(400M-470M)A": 210,
        "F6(400M-470M)B": 211,
        "F7(470M-600M)A": 212,
        "F7(470M-600M)B": 213
        }

VFO_CHANNEL_NAMES = ["F1(50M-76M)A", "F1(50M-76M)B",
                     "F2(108M-136M)A", "F2(108M-136M)B",
                     "F3(136M-174M)A", "F3(136M-174M)B",
                     "F4(174M-350M)A", "F4(174M-350M)B",
                     "F5(350M-400M)A", "F5(350M-400M)B",
                     "F6(400M-470M)A", "F6(400M-470M)B",
                     "F7(470M-600M)A", "F7(470M-600M)B"]

SCANLIST_LIST = ["None", "1", "2", "1+2"]

DTMF_CHARS = "0123456789ABCD*# "
DTMF_CHARS_ID = "0123456789ABCDabcd"
DTMF_CHARS_KILL = "0123456789ABCDabcd"
DTMF_CHARS_UPDOWN = "0123456789ABCDabcd#* "
DTMF_CODE_CHARS = "ABCD*# "
DTMF_DECODE_RESPONSE_LIST = ["None", "Ring", "Reply", "Both"]

KEYACTIONS_LIST = ["None", "Flashlight on/off", "Power select",
                   "Monitor", "Scan on/off", "VOX on/off",
                   "Alarm on/off", "FM radio on/off", "Transmit 1750 Hz"]


FONT_MAPPING = {
    128: {1: '一', 2: '乙', 3: '二', 4: '十', 5: '丁', 6: '厂', 7: '七', 8: '卜', 9: '八', 10: '人', 11: '入', 12: '乂',
          13: '儿', 14: '九', 15: '匕', 16: '几', 17: '刁', 18: '了', 19: '乃', 20: '刀', 21: '力', 22: '又', 23: '乜',
          24: '三', 25: '干', 26: '亍', 27: '于', 28: '亏', 29: '士', 30: '土', 31: '工', 32: '才', 33: '下', 34: '寸',
          35: '丈', 36: '大', 37: '兀', 38: '与', 39: '万', 40: '弋', 41: '上', 42: '小', 43: '口', 44: '山', 45: '巾',
          46: '千', 47: '乞', 48: '川', 49: '亿', 50: '彳', 51: '个', 52: '么', 53: '久', 54: '勺', 55: '丸', 56: '夕',
          57: '凡', 58: '及', 59: '广', 60: '亡', 61: '门', 62: '丫', 63: '义', 64: '之', 65: '尸', 66: '已', 67: '巳',
          68: '弓', 69: '己', 70: '卫', 71: '孑', 72: '子', 73: '孓', 74: '也', 75: '女', 76: '飞', 77: '刃', 78: '习',
          79: '叉', 80: '马', 81: '乡', 82: '幺', 83: '丰', 84: '王', 85: '井', 86: '开', 87: '亓', 88: '夫', 89: '天',
          90: '元', 91: '无', 92: '韦', 93: '云', 94: '专', 95: '丐', 96: '扎', 97: '廿', 98: '艺', 99: '木', 100: '五',
          101: '支', 102: '厅', 103: '卅', 104: '不', 105: '仄', 106: '太', 107: '犬', 108: '区', 109: '历', 110: '友',
          111: '歹', 112: '尤', 113: '匹', 114: '厄', 115: '车', 116: '巨', 117: '牙', 118: '屯', 119: '戈', 120: '比',
          121: '互', 122: '切', 123: '瓦', 124: '止', 125: '少', 126: '曰', 127: '日', 128: '中', 129: '贝', 130: '内',
          131: '水', 132: '冈', 133: '见', 134: '手', 135: '午', 136: '牛', 137: '毛', 138: '气', 139: '壬', 140: '升',
          141: '夭', 142: '长', 143: '仁', 144: '仃', 145: '什', 146: '片', 147: '仆', 148: '仉', 149: '化', 150: '仇',
          151: '币', 152: '仂', 153: '仍', 154: '仅', 155: '斤', 156: '爪', 157: '反', 158: '兮', 159: '刈', 160: '介',
          161: '父', 162: '爻', 163: '从', 164: '仑', 165: '今', 166: '凶', 167: '分', 168: '乏', 169: '公', 170: '仓',
          171: '月', 172: '氏', 173: '勿', 174: '风', 175: '欠', 176: '丹', 177: '匀', 178: '乌', 179: '勾', 180: '殳',
          181: '凤', 182: '卞', 183: '六', 184: '文', 185: '亢', 186: '方', 187: '闩', 188: '火', 189: '为', 190: '斗',
          191: '忆', 192: '计', 193: '订', 194: '户', 195: '讣', 196: '认', 197: '讥', 198: '冗', 199: '心', 200: '尹',
          201: '尺', 202: '夬', 203: '引', 204: '丑', 205: '爿', 206: '巴', 207: '孔', 208: '队', 209: '办', 210: '以',
          211: '允', 212: '邓', 213: '予', 214: '劝', 215: '双', 216: '书', 217: '毋', 218: '幻', 219: '玉', 220: '刊',
          221: '末', 222: '未', 223: '示', 224: '击', 225: '邗', 226: '戋', 227: '打', 228: '巧', 229: '正', 230: '扑',
          231: '卉', 232: '扒', 233: '邛', 234: '功', 235: '扔', 236: '去', 237: '甘', 238: '世', 239: '艾', 240: '艽',
          241: '古', 242: '节', 243: '艿', 244: '本', 245: '术', 246: '札', 247: '可', 248: '叵', 249: '匝', 250: '丙',
          251: '左', 252: '厉', 253: '丕', 254: '石', 255: '右'},
    129: {1: '布', 2: '夯', 3: '龙', 4: '戊', 5: '平', 6: '灭', 7: '轧', 8: '东', 9: '匜', 10: '劢', 11: '卡', 12: '北',
          13: '占', 14: '凸', 15: '卢', 16: '业', 17: '旧', 18: '帅', 19: '归', 20: '目', 21: '旦', 22: '且', 23: '叮',
          24: '叶', 25: '甲', 26: '申', 27: '号', 28: '电', 29: '田', 30: '由', 31: '卟', 32: '叭', 33: '只', 34: '央',
          35: '史', 36: '叱', 37: '叽', 38: '兄', 39: '叼', 40: '叩', 41: '叫', 42: '叻', 43: '叨', 44: '另', 45: '叹',
          46: '冉', 47: '皿', 48: '凹', 49: '囚', 50: '四', 51: '生', 52: '失', 53: '矢', 54: '氕', 55: '乍', 56: '禾',
          57: '仨', 58: '仕', 59: '丘', 60: '付', 61: '仗', 62: '代', 63: '仙', 64: '仟', 65: '仡', 66: '仫', 67: '伋',
          68: '们', 69: '仪', 70: '白', 71: '仔', 72: '他', 73: '仞', 74: '斥', 75: '卮', 76: '瓜', 77: '乎', 78: '丛',
          79: '令', 80: '用', 81: '甩', 82: '印', 83: '氐', 84: '乐', 85: '尔', 86: '句', 87: '匆', 88: '犰', 89: '册',
          90: '卯', 91: '犯', 92: '外', 93: '处', 94: '冬', 95: '鸟', 96: '务', 97: '刍', 98: '包', 99: '饥', 100: '主',
          101: '市', 102: '庀', 103: '邝', 104: '立', 105: '冯', 106: '邙', 107: '玄', 108: '闪', 109: '兰', 110: '半',
          111: '汀', 112: '汁', 113: '汇', 114: '头', 115: '汈', 116: '汉', 117: '忉', 118: '宁', 119: '穴', 120: '宄',
          121: '它', 122: '讦', 123: '讧', 124: '讨', 125: '写', 126: '让', 127: '礼', 128: '讪', 129: '讫', 130: '训',
          131: '必', 132: '议', 133: '讯', 134: '记', 135: '永', 136: '司', 137: '尻', 138: '尼', 139: '民', 140: '弗',
          141: '弘', 142: '阢', 143: '出', 144: '阡', 145: '辽', 146: '奶', 147: '奴', 148: '尕', 149: '加', 150: '召',
          151: '皮', 152: '边', 153: '孕', 154: '发', 155: '圣', 156: '对', 157: '弁', 158: '台', 159: '矛', 160: '纠',
          161: '驭', 162: '母', 163: '幼', 164: '丝', 165: '匡', 166: '耒', 167: '邦', 168: '玎', 169: '玑', 170: '式',
          171: '迂', 172: '刑', 173: '邢', 174: '戎', 175: '动', 176: '圩', 177: '圬', 178: '圭', 179: '扛', 180: '寺',
          181: '吉', 182: '扣', 183: '扦', 184: '圪', 185: '考', 186: '托', 187: '圳', 188: '老', 189: '圾', 190: '巩',
          191: '执', 192: '扩', 193: '圹', 194: '扪', 195: '扫', 196: '圯', 197: '圮', 198: '地', 199: '扬', 200: '场',
          201: '耳', 202: '芋', 203: '芏', 204: '共', 205: '芊', 206: '芍', 207: '芨', 208: '芄', 209: '芒', 210: '亚',
          211: '芝', 212: '芎', 213: '芑', 214: '芗', 215: '朽', 216: '朴', 217: '机', 218: '权', 219: '过', 220: '亘',
          221: '臣', 222: '吏', 223: '再', 224: '协', 225: '西', 226: '压', 227: '厌', 228: '厍', 229: '戌', 230: '在',
          231: '百', 232: '有', 233: '存', 234: '而', 235: '页', 236: '匠', 237: '夸', 238: '夺', 239: '夼', 240: '灰',
          241: '达', 242: '戍', 243: '尥', 244: '列', 245: '死', 246: '成', 247: '夹', 248: '夷', 249: '轨', 250: '邪',
          251: '尧', 252: '划', 253: '迈', 254: '毕', 255: '至'},
    130: {1: '此', 2: '乩', 3: '贞', 4: '师', 5: '尘', 6: '尖', 7: '劣', 8: '光', 9: '当', 10: '吁', 11: '早', 12: '吐',
          13: '吓', 14: '旯', 15: '曳', 16: '虫', 17: '曲', 18: '团', 19: '同', 20: '吕', 21: '吊', 22: '吃', 23: '因',
          24: '吸', 25: '吗', 26: '吆', 27: '屿', 28: '屹', 29: '岌', 30: '帆', 31: '岁', 32: '回', 33: '岂', 34: '屺',
          35: '则', 36: '刚', 37: '网', 38: '肉', 39: '凼', 40: '囝', 41: '囡', 42: '钆', 43: '钇', 44: '年', 45: '朱',
          46: '缶', 47: '氘', 48: '氖', 49: '牝', 50: '先', 51: '丢', 52: '廷', 53: '舌', 54: '竹', 55: '迁', 56: '乔',
          57: '迄', 58: '伟', 59: '传', 60: '乒', 61: '乓', 62: '休', 63: '伍', 64: '伎', 65: '伏', 66: '伛', 67: '优',
          68: '臼', 69: '伢', 70: '伐', 71: '仳', 72: '延', 73: '佤', 74: '仲', 75: '仵', 76: '件', 77: '任', 78: '伤',
          79: '伥', 80: '价', 81: '伦', 82: '份', 83: '伧', 84: '华', 85: '仰', 86: '伉', 87: '仿', 88: '伙', 89: '伪',
          90: '伫', 91: '自', 92: '伊', 93: '血', 94: '向', 95: '囟', 96: '似', 97: '后', 98: '行', 99: '甪', 100: '舟',
          101: '全', 102: '会', 103: '杀', 104: '合', 105: '兆', 106: '企', 107: '汆', 108: '氽', 109: '众', 110: '爷',
          111: '伞', 112: '创', 113: '刖', 114: '肌', 115: '肋', 116: '朵', 117: '杂', 118: '夙', 119: '危', 120: '旬',
          121: '旭', 122: '旮', 123: '旨', 124: '负', 125: '犴', 126: '刎', 127: '犷', 128: '匈', 129: '犸', 130: '舛',
          131: '各', 132: '名', 133: '多', 134: '凫', 135: '争', 136: '邬', 137: '色', 138: '饧', 139: '冱', 140: '壮',
          141: '冲', 142: '妆', 143: '冰', 144: '庄', 145: '庆', 146: '亦', 147: '刘', 148: '齐', 149: '交', 150: '次',
          151: '衣', 152: '产', 153: '决', 154: '亥', 155: '邡', 156: '充', 157: '妄', 158: '闭', 159: '问', 160: '闯',
          161: '羊', 162: '并', 163: '关', 164: '米', 165: '灯', 166: '州', 167: '汗', 168: '污', 169: '江', 170: '汕',
          171: '汔', 172: '汲', 173: '汐', 174: '汛', 175: '汜', 176: '池', 177: '汝', 178: '汤', 179: '汊', 180: '忖',
          181: '忏', 182: '忙', 183: '兴', 184: '宇', 185: '守', 186: '宅', 187: '字', 188: '安', 189: '讲', 190: '讳',
          191: '讴', 192: '军', 193: '讵', 194: '讶', 195: '祁', 196: '讷', 197: '许', 198: '讹', 199: '论', 200: '讼',
          201: '农', 202: '讽', 203: '设', 204: '访', 205: '诀', 206: '聿', 207: '寻', 208: '那', 209: '艮', 210: '厾',
          211: '迅', 212: '尽', 213: '导', 214: '异', 215: '弛', 216: '阱', 217: '阮', 218: '孙', 219: '阵', 220: '阳',
          221: '收', 222: '阪', 223: '阶', 224: '阴', 225: '防', 226: '丞', 227: '奸', 228: '如', 229: '妁', 230: '妇',
          231: '妃', 232: '好', 233: '她', 234: '妈', 235: '戏', 236: '羽', 237: '观', 238: '牟', 239: '欢', 240: '买',
          241: '纡', 242: '红', 243: '纣', 244: '驮', 245: '纤', 246: '纥', 247: '驯', 248: '纨', 249: '约', 250: '级',
          251: '纩', 252: '纪', 253: '驰', 254: '纫', 255: '巡'},
    131: {1: '寿', 2: '玕', 3: '弄', 4: '玙', 5: '麦', 6: '玖', 7: '玚', 8: '玛', 9: '形', 10: '进', 11: '戒', 12: '吞',
          13: '远', 14: '违', 15: '韧', 16: '运', 17: '扶', 18: '抚', 19: '坛', 20: '抟', 21: '技', 22: '坏', 23: '抔',
          24: '抠', 25: '坜', 26: '扰', 27: '扼', 28: '拒', 29: '找', 30: '批', 31: '扯', 32: '址', 33: '走', 34: '抄',
          35: '汞', 36: '坝', 37: '贡', 38: '攻', 39: '赤', 40: '圻', 41: '折', 42: '抓', 43: '扳', 44: '坂', 45: '抡',
          46: '扮', 47: '抢', 48: '扺', 49: '孝', 50: '坎', 51: '坍', 52: '均', 53: '坞', 54: '抑', 55: '抛', 56: '投',
          57: '抃', 58: '坟', 59: '坑', 60: '抗', 61: '坊', 62: '抖', 63: '护', 64: '壳', 65: '志', 66: '扭', 67: '块',
          68: '抉', 69: '声', 70: '把', 71: '报', 72: '拟', 73: '抒', 74: '却', 75: '劫', 76: '毐', 77: '芙', 78: '芫',
          79: '芜', 80: '苇', 81: '邯', 82: '芸', 83: '芾', 84: '芰', 85: '苈', 86: '苊', 87: '苣', 88: '芽', 89: '芷',
          90: '芮', 91: '苋', 92: '芼', 93: '苌', 94: '花', 95: '芹', 96: '芥', 97: '苁', 98: '芩', 99: '芬', 100: '苍',
          101: '芪', 102: '芴', 103: '芡', 104: '芟', 105: '苄', 106: '芳', 107: '严', 108: '苎', 109: '芦', 110: '芯',
          111: '劳', 112: '克', 113: '芭', 114: '苏', 115: '苡', 116: '杆', 117: '杜', 118: '杠', 119: '材', 120: '村',
          121: '杖', 122: '杌', 123: '杏', 124: '杉', 125: '巫', 126: '杓', 127: '极', 128: '杧', 129: '杞', 130: '李',
          131: '杨', 132: '杈', 133: '求', 134: '忑', 135: '孛', 136: '甫', 137: '匣', 138: '更', 139: '束', 140: '吾',
          141: '豆', 142: '两', 143: '邴', 144: '酉', 145: '丽', 146: '医', 147: '辰', 148: '励', 149: '邳', 150: '否',
          151: '还', 152: '矶', 153: '奁', 154: '豕', 155: '尬', 156: '歼', 157: '来', 158: '忒', 159: '连', 160: '欤',
          161: '轩', 162: '轪', 163: '轫', 164: '迓', 165: '邶', 166: '忐', 167: '芈', 168: '步', 169: '卤', 170: '卣',
          171: '邺', 172: '坚', 173: '肖', 174: '旰', 175: '旱', 176: '盯', 177: '呈', 178: '时', 179: '吴', 180: '呋',
          181: '助', 182: '县', 183: '里', 184: '呓', 185: '呆', 186: '吱', 187: '吠', 188: '呔', 189: '呕', 190: '园',
          191: '呖', 192: '呃', 193: '旷', 194: '围', 195: '呀', 196: '吨', 197: '旸', 198: '吡', 199: '町', 200: '足',
          201: '虬', 202: '邮', 203: '男', 204: '困', 205: '吵', 206: '串', 207: '呙', 208: '呐', 209: '呗', 210: '员',
          211: '听', 212: '吟', 213: '吩', 214: '呛', 215: '吻', 216: '吹', 217: '呜', 218: '吭', 219: '吣', 220: '吲',
          221: '吼', 222: '邑', 223: '吧', 224: '囤', 225: '别', 226: '吮', 227: '岍', 228: '帏', 229: '岐', 230: '岖',
          231: '岈', 232: '岗', 233: '岘', 234: '帐', 235: '岑', 236: '岚', 237: '兕', 238: '财', 239: '囵', 240: '囫',
          241: '钉', 242: '针', 243: '钊', 244: '钋', 245: '钌', 246: '迕', 247: '氙', 248: '氚', 249: '牡', 250: '告',
          251: '我', 252: '乱', 253: '利', 254: '秃', 255: '秀'},
    132: {1: '私', 2: '岙', 3: '每', 4: '佞', 5: '兵', 6: '邱', 7: '估', 8: '体', 9: '何', 10: '佐', 11: '伾', 12: '佑',
          13: '攸', 14: '但', 15: '伸', 16: '佃', 17: '佚', 18: '作', 19: '伯', 20: '伶', 21: '佣', 22: '低', 23: '你',
          24: '佝', 25: '佟', 26: '住', 27: '位', 28: '伴', 29: '佗', 30: '身', 31: '皂', 32: '伺', 33: '佛', 34: '伽',
          35: '囱', 36: '近', 37: '彻', 38: '役', 39: '彷', 40: '返', 41: '佘', 42: '余', 43: '希', 44: '佥', 45: '坐',
          46: '谷', 47: '孚', 48: '妥', 49: '豸', 50: '含', 51: '邻', 52: '坌', 53: '岔', 54: '肝', 55: '肟', 56: '肛',
          57: '肚', 58: '肘', 59: '肠', 60: '邸', 61: '龟', 62: '甸', 63: '奂', 64: '免', 65: '劬', 66: '狂', 67: '犹',
          68: '狈', 69: '狄', 70: '角', 71: '删', 72: '狃', 73: '狁', 74: '鸠', 75: '条', 76: '彤', 77: '卵', 78: '灸',
          79: '岛', 80: '邹', 81: '刨', 82: '饨', 83: '迎', 84: '饩', 85: '饪', 86: '饫', 87: '饬', 88: '饭', 89: '饮',
          90: '系', 91: '言', 92: '冻', 93: '状', 94: '亩', 95: '况', 96: '亨', 97: '庑', 98: '床', 99: '庋', 100: '库',
          101: '庇', 102: '疔', 103: '疖', 104: '疗', 105: '吝', 106: '应', 107: '冷', 108: '这', 109: '庐', 110: '序',
          111: '辛', 112: '肓', 113: '弃', 114: '冶', 115: '忘', 116: '闰', 117: '闱', 118: '闲', 119: '闳', 120: '间',
          121: '闵', 122: '闶', 123: '闷', 124: '羌', 125: '判', 126: '兑', 127: '灶', 128: '灿', 129: '灼', 130: '炀',
          131: '弟', 132: '沣', 133: '汪', 134: '沅', 135: '沄', 136: '沐', 137: '沛', 138: '沔', 139: '汰', 140: '沤',
          141: '沥', 142: '沌', 143: '沘', 144: '沏', 145: '沚', 146: '沙', 147: '汩', 148: '汨', 149: '汭', 150: '汽',
          151: '沃', 152: '沂', 153: '沦', 154: '汹', 155: '汾', 156: '泛', 157: '沧', 158: '沨', 159: '沟', 160: '没',
          161: '汴', 162: '汶', 163: '沆', 164: '沩', 165: '沪', 166: '沈', 167: '沉', 168: '沁', 169: '泐', 170: '怃',
          171: '忮', 172: '怀', 173: '怄', 174: '忧', 175: '忡', 176: '忤', 177: '忾', 178: '怅', 179: '忻', 180: '忪',
          181: '怆', 182: '忭', 183: '忱', 184: '快', 185: '忸', 186: '完', 187: '宋', 188: '宏', 189: '牢', 190: '究',
          191: '穷', 192: '灾', 193: '良', 194: '证', 195: '诂', 196: '诃', 197: '启', 198: '评', 199: '补', 200: '初',
          201: '社', 202: '祀', 203: '祃', 204: '诅', 205: '识', 206: '诈', 207: '诉', 208: '罕', 209: '诊', 210: '诋',
          211: '诌', 212: '词', 213: '诎', 214: '诏', 215: '诐', 216: '译', 217: '诒', 218: '君', 219: '灵', 220: '即',
          221: '层', 222: '屁', 223: '屃', 224: '尿', 225: '尾', 226: '迟', 227: '局', 228: '改', 229: '张', 230: '忌',
          231: '际', 232: '陆', 233: '阿', 234: '孜', 235: '陇', 236: '陈', 237: '阽', 238: '阻', 239: '阼', 240: '附',
          241: '坠', 242: '陀', 243: '陂', 244: '陉', 245: '妍', 246: '妩', 247: '妓', 248: '妪', 249: '妣', 250: '妙',
          251: '妊', 252: '妖', 253: '妗', 254: '姊', 255: '妨'},
    133: {1: '妫', 2: '妒', 3: '妞', 4: '姒', 5: '妤', 6: '努', 7: '邵', 8: '劭', 9: '忍', 10: '刭', 11: '劲', 12: '甬',
          13: '邰', 14: '矣', 15: '鸡', 16: '纬', 17: '纭', 18: '驱', 19: '纯', 20: '纰', 21: '纱', 22: '纲', 23: '纳',
          24: '纴', 25: '纵', 26: '驳', 27: '纶', 28: '纷', 29: '纸', 30: '纹', 31: '纺', 32: '纻', 33: '驴', 34: '纽',
          35: '纾', 36: '奉', 37: '玩', 38: '玮', 39: '环', 40: '玡', 41: '武', 42: '青', 43: '责', 44: '现', 45: '玫',
          46: '玠', 47: '玢', 48: '玥', 49: '表', 50: '玦', 51: '甙', 52: '盂', 53: '忝', 54: '规', 55: '匦', 56: '抹',
          57: '卦', 58: '邽', 59: '坩', 60: '坷', 61: '坯', 62: '拓', 63: '垅', 64: '拢', 65: '拔', 66: '抨', 67: '坪',
          68: '拣', 69: '拤', 70: '拈', 71: '坫', 72: '垆', 73: '坦', 74: '担', 75: '坤', 76: '押', 77: '抻', 78: '抽',
          79: '拐', 80: '拃', 81: '拖', 82: '拊', 83: '者', 84: '拍', 85: '顶', 86: '坼', 87: '拆', 88: '拎', 89: '拥',
          90: '抵', 91: '坻', 92: '拘', 93: '势', 94: '抱', 95: '拄', 96: '垃', 97: '拉', 98: '拦', 99: '幸', 100: '拌',
          101: '拧', 102: '坨', 103: '坭', 104: '抿', 105: '拂', 106: '拙', 107: '招', 108: '坡', 109: '披', 110: '拨',
          111: '择', 112: '拚', 113: '抬', 114: '拇', 115: '坳', 116: '拗', 117: '耵', 118: '其', 119: '耶', 120: '取',
          121: '茉', 122: '苷', 123: '苦', 124: '苯', 125: '昔', 126: '苛', 127: '苤', 128: '若', 129: '茂', 130: '茏',
          131: '苹', 132: '苫', 133: '苴', 134: '苜', 135: '苗', 136: '英', 137: '苒', 138: '苘', 139: '茌', 140: '苻',
          141: '苓', 142: '茚', 143: '苟', 144: '茆', 145: '茑', 146: '苑', 147: '苞', 148: '范', 149: '茓', 150: '茔',
          151: '茕', 152: '直', 153: '苠', 154: '茀', 155: '茁', 156: '茄', 157: '苕', 158: '茎', 159: '苔', 160: '茅',
          161: '枉', 162: '林', 163: '枝', 164: '杯', 165: '枢', 166: '枥', 167: '柜', 168: '枇', 169: '杪', 170: '杳',
          171: '枘', 172: '枧', 173: '杵', 174: '枚', 175: '枨', 176: '析', 177: '板', 178: '枞', 179: '松', 180: '枪',
          181: '枫', 182: '构', 183: '杭', 184: '枋', 185: '杰', 186: '述', 187: '枕', 188: '杻', 189: '杷', 190: '杼',
          191: '丧', 192: '或', 193: '画', 194: '卧', 195: '事', 196: '刺', 197: '枣', 198: '雨', 199: '卖', 200: '矸',
          201: '郁', 202: '矻', 203: '矾', 204: '矽', 205: '矿', 206: '砀', 207: '码', 208: '厕', 209: '奈', 210: '刳',
          211: '奔', 212: '奇', 213: '奄', 214: '奋', 215: '态', 216: '瓯', 217: '欧', 218: '殴', 219: '垄', 220: '殁',
          221: '郏', 222: '妻', 223: '轰', 224: '顷', 225: '转', 226: '轭', 227: '斩', 228: '轮', 229: '软', 230: '到',
          231: '郅', 232: '鸢', 233: '非', 234: '叔', 235: '歧', 236: '肯', 237: '齿', 238: '些', 239: '卓', 240: '虎',
          241: '虏', 242: '肾', 243: '贤', 244: '尚', 245: '盱', 246: '旺', 247: '具', 248: '昊', 249: '昙', 250: '果',
          251: '味', 252: '杲', 253: '昃', 254: '昆', 255: '国'},
    134: {1: '哎', 2: '咕', 3: '昌', 4: '呵', 5: '咂', 6: '畅', 7: '呸', 8: '昕', 9: '明', 10: '易', 11: '咙', 12: '昀',
          13: '昂', 14: '旻', 15: '昉', 16: '炅', 17: '咔', 18: '畀', 19: '虮', 20: '迪', 21: '典', 22: '固', 23: '忠',
          24: '咀', 25: '呷', 26: '呻', 27: '黾', 28: '咒', 29: '咋', 30: '咐', 31: '呱', 32: '呼', 33: '呤', 34: '咚',
          35: '鸣', 36: '咆', 37: '咛', 38: '咏', 39: '呢', 40: '咄', 41: '呶', 42: '咖', 43: '呦', 44: '咝', 45: '岵',
          46: '岢', 47: '岸', 48: '岩', 49: '帖', 50: '罗', 51: '岿', 52: '岬', 53: '岫', 54: '帜', 55: '帙', 56: '帕',
          57: '岭', 58: '岣', 59: '峁', 60: '刿', 61: '峂', 62: '迥', 63: '岷', 64: '剀', 65: '凯', 66: '帔', 67: '峄',
          68: '沓', 69: '败', 70: '账', 71: '贩', 72: '贬', 73: '购', 74: '贮', 75: '囹', 76: '图', 77: '罔', 78: '钍',
          79: '钎', 80: '钏', 81: '钐', 82: '钓', 83: '钒', 84: '钔', 85: '钕', 86: '钗', 87: '邾', 88: '制', 89: '知',
          90: '迭', 91: '氛', 92: '迮', 93: '垂', 94: '牦', 95: '牧', 96: '物', 97: '乖', 98: '刮', 99: '秆', 100: '和',
          101: '季', 102: '委', 103: '竺', 104: '秉', 105: '迤', 106: '佳', 107: '侍', 108: '佶', 109: '岳', 110: '佬',
          111: '佴', 112: '供', 113: '使', 114: '侑', 115: '佰', 116: '侉', 117: '例', 118: '侠', 119: '臾', 120: '侥',
          121: '版', 122: '侄', 123: '岱', 124: '侦', 125: '侣', 126: '侗', 127: '侃', 128: '侧', 129: '侏', 130: '凭',
          131: '侨', 132: '侩', 133: '佻', 134: '佾', 135: '佩', 136: '货', 137: '侈', 138: '侪', 139: '佼', 140: '依',
          141: '佯', 142: '侬', 143: '帛', 144: '卑', 145: '的', 146: '迫', 147: '阜', 148: '侔', 149: '质', 150: '欣',
          151: '郈', 152: '征', 153: '徂', 154: '往', 155: '爬', 156: '彼', 157: '径', 158: '所', 159: '舍', 160: '金',
          161: '刽', 162: '郐', 163: '刹', 164: '命', 165: '肴', 166: '郄', 167: '斧', 168: '怂', 169: '爸', 170: '采',
          171: '籴', 172: '觅', 173: '受', 174: '乳', 175: '贪', 176: '念', 177: '贫', 178: '忿', 179: '瓮', 180: '戗',
          181: '肼', 182: '肤', 183: '朊', 184: '肺', 185: '肢', 186: '肽', 187: '肱', 188: '肫', 189: '肿', 190: '肭',
          191: '胀', 192: '朋', 193: '肷', 194: '股', 195: '肮', 196: '肪', 197: '肥', 198: '服', 199: '胁', 200: '周',
          201: '剁', 202: '昏', 203: '迩', 204: '郇', 205: '鱼', 206: '兔', 207: '狉', 208: '狙', 209: '狎', 210: '狐',
          211: '忽', 212: '狝', 213: '狗', 214: '狍', 215: '狞', 216: '狒', 217: '咎', 218: '备', 219: '炙', 220: '枭',
          221: '饯', 222: '饰', 223: '饱', 224: '饲', 225: '饳', 226: '饴', 227: '冽', 228: '变', 229: '京', 230: '享',
          231: '冼', 232: '庞', 233: '店', 234: '夜', 235: '庙', 236: '府', 237: '底', 238: '庖', 239: '疟', 240: '疠',
          241: '疝', 242: '疙', 243: '疚', 244: '疡', 245: '剂', 246: '卒', 247: '郊', 248: '兖', 249: '庚', 250: '废',
          251: '净', 252: '妾', 253: '盲', 254: '放', 255: '於'},
    135: {1: '刻', 2: '劾', 3: '育', 4: '氓', 5: '闸', 6: '闹', 7: '郑', 8: '券', 9: '卷', 10: '单', 11: '炜', 12: '炬',
          13: '炖', 14: '炒', 15: '炝', 16: '炊', 17: '炕', 18: '炎', 19: '炉', 20: '炔', 21: '沫', 22: '浅', 23: '法',
          24: '泔', 25: '泄', 26: '沽', 27: '沭', 28: '河', 29: '泷', 30: '沾', 31: '泸', 32: '沮', 33: '泪', 34: '油',
          35: '泱', 36: '泅', 37: '泗', 38: '泊', 39: '泠', 40: '泜', 41: '泺', 42: '泃', 43: '沿', 44: '泖', 45: '泡',
          46: '注', 47: '泣', 48: '泫', 49: '泮', 50: '泞', 51: '沱', 52: '泻', 53: '泌', 54: '泳', 55: '泥', 56: '泯',
          57: '沸', 58: '泓', 59: '沼', 60: '波', 61: '泼', 62: '泽', 63: '泾', 64: '治', 65: '怔', 66: '怯', 67: '怙',
          68: '怵', 69: '怖', 70: '怦', 71: '怛', 72: '怏', 73: '性', 74: '怍', 75: '怕', 76: '怜', 77: '怩', 78: '怫',
          79: '怊', 80: '怿', 81: '怪', 82: '怡', 83: '学', 84: '宝', 85: '宗', 86: '定', 87: '宕', 88: '宠', 89: '宜',
          90: '审', 91: '宙', 92: '官', 93: '空', 94: '帘', 95: '穸', 96: '穹', 97: '宛', 98: '实', 99: '宓', 100: '诓',
          101: '诔', 102: '试', 103: '郎', 104: '诖', 105: '诗', 106: '诘', 107: '戾', 108: '肩', 109: '房', 110: '诙',
          111: '戽', 112: '诚', 113: '郓', 114: '衬', 115: '衫', 116: '衩', 117: '祆', 118: '祎', 119: '祉', 120: '视',
          121: '祈', 122: '诛', 123: '诜', 124: '话', 125: '诞', 126: '诟', 127: '诠', 128: '诡', 129: '询', 130: '诣',
          131: '诤', 132: '该', 133: '详', 134: '诧', 135: '诨', 136: '诩', 137: '建', 138: '肃', 139: '隶', 140: '录',
          141: '帚', 142: '屉', 143: '居', 144: '届', 145: '刷', 146: '鸤', 147: '屈', 148: '弧', 149: '弥', 150: '弦',
          151: '承', 152: '孟', 153: '陋', 154: '戕', 155: '陌', 156: '孤', 157: '孢', 158: '陕', 159: '亟', 160: '降',
          161: '函', 162: '陔', 163: '限', 164: '卺', 165: '妹', 166: '姑', 167: '姐', 168: '妲', 169: '妯', 170: '姓',
          171: '姗', 172: '妮', 173: '始', 174: '帑', 175: '弩', 176: '孥', 177: '驽', 178: '姆', 179: '虱', 180: '迦',
          181: '迢', 182: '驾', 183: '叁', 184: '参', 185: '迨', 186: '艰', 187: '线', 188: '绀', 189: '绁', 190: '绂',
          191: '练', 192: '驵', 193: '组', 194: '绅', 195: '细', 196: '驶', 197: '织', 198: '驷', 199: '驸', 200: '驹',
          201: '终', 202: '绉', 203: '驺', 204: '驻', 205: '绊', 206: '驼', 207: '绋', 208: '绌', 209: '绍', 210: '驿',
          211: '绎', 212: '经', 213: '骀', 214: '贯', 215: '甾', 216: '砉', 217: '耔', 218: '契', 219: '贰', 220: '奏',
          221: '春', 222: '帮', 223: '珏', 224: '珐', 225: '珂', 226: '珑', 227: '玷', 228: '玳', 229: '珀', 230: '顸',
          231: '珍', 232: '玲', 233: '珊', 234: '珉', 235: '珈', 236: '玻', 237: '毒', 238: '型', 239: '韨', 240: '拭',
          241: '挂', 242: '封', 243: '持', 244: '拮', 245: '拷', 246: '拱', 247: '垭', 248: '挝', 249: '垣', 250: '项',
          251: '垮', 252: '挎', 253: '垯', 254: '挞', 255: '城'},
    136: {1: '挟', 2: '挠', 3: '垤', 4: '政', 5: '赴', 6: '赵', 7: '赳', 8: '贲', 9: '垱', 10: '挡', 11: '拽', 12: '垌',
          13: '哉', 14: '垲', 15: '挺', 16: '括', 17: '挢', 18: '埏', 19: '郝', 20: '垍', 21: '垧', 22: '垢', 23: '拴',
          24: '拾', 25: '挑', 26: '垛', 27: '指', 28: '垫', 29: '挣', 30: '挤', 31: '垓', 32: '垟', 33: '拼', 34: '垞',
          35: '挖', 36: '按', 37: '挥', 38: '挦', 39: '挪', 40: '垠', 41: '拯', 42: '拶', 43: '某', 44: '甚', 45: '荆',
          46: '茸', 47: '革', 48: '茜', 49: '茬', 50: '荐', 51: '荙', 52: '巷', 53: '荚', 54: '荑', 55: '贳', 56: '荛',
          57: '荜', 58: '茈', 59: '带', 60: '草', 61: '茧', 62: '茼', 63: '莒', 64: '茵', 65: '茴', 66: '茱', 67: '莛',
          68: '荞', 69: '茯', 70: '荏', 71: '荇', 72: '荃', 73: '荟', 74: '茶', 75: '荀', 76: '茗', 77: '荠', 78: '茭',
          79: '茨', 80: '荒', 81: '垩', 82: '茳', 83: '茫', 84: '荡', 85: '荣', 86: '荤', 87: '荥', 88: '荦', 89: '荧',
          90: '荨', 91: '茛', 92: '故', 93: '荩', 94: '胡', 95: '荪', 96: '荫', 97: '茹', 98: '荔', 99: '南', 100: '荬',
          101: '荭', 102: '药', 103: '柰', 104: '标', 105: '栈', 106: '柑', 107: '枯', 108: '栉', 109: '柯', 110: '柄',
          111: '柘', 112: '栊', 113: '柩', 114: '枰', 115: '栋', 116: '栌', 117: '相', 118: '查', 119: '柙', 120: '枵',
          121: '柚', 122: '枳', 123: '柞', 124: '柏', 125: '柝', 126: '栀', 127: '柃', 128: '柢', 129: '栎', 130: '枸',
          131: '栅', 132: '柳', 133: '柱', 134: '柿', 135: '栏', 136: '柈', 137: '柠', 138: '柁', 139: '枷', 140: '柽',
          141: '树', 142: '勃', 143: '剌', 144: '郚', 145: '剅', 146: '要', 147: '酊', 148: '郦', 149: '柬', 150: '咸',
          151: '威', 152: '歪', 153: '甭', 154: '研', 155: '砖', 156: '厘', 157: '砗', 158: '厚', 159: '砑', 160: '砘',
          161: '砒', 162: '砌', 163: '砂', 164: '泵', 165: '砚', 166: '斫', 167: '砭', 168: '砜', 169: '砍', 170: '面',
          171: '耐', 172: '耍', 173: '奎', 174: '耷', 175: '牵', 176: '鸥', 177: '虺', 178: '残', 179: '殂', 180: '殃',
          181: '殇', 182: '殄', 183: '殆', 184: '轱', 185: '轲', 186: '轳', 187: '轴', 188: '轵', 189: '轶', 190: '轷',
          191: '轸', 192: '轹', 193: '轺', 194: '轻', 195: '鸦', 196: '虿', 197: '皆', 198: '毖', 199: '韭', 200: '背',
          201: '战', 202: '觇', 203: '点', 204: '虐', 205: '临', 206: '览', 207: '竖', 208: '尜', 209: '省', 210: '削',
          211: '尝', 212: '哐', 213: '昧', 214: '眄', 215: '眍', 216: '盹', 217: '是', 218: '郢', 219: '眇', 220: '眊',
          221: '盼', 222: '眨', 223: '昽', 224: '眈', 225: '哇', 226: '咭', 227: '哄', 228: '哑', 229: '显', 230: '冒',
          231: '映', 232: '禺', 233: '哂', 234: '星', 235: '昨', 236: '咴', 237: '曷', 238: '昴', 239: '咧', 240: '昱',
          241: '昵', 242: '咦', 243: '哓', 244: '昭', 245: '哔', 246: '畎', 247: '畏', 248: '毗', 249: '趴', 250: '呲',
          251: '胄', 252: '胃', 253: '贵', 254: '畋', 255: '畈'},
    137: {1: '界', 2: '虹', 3: '虾', 4: '虼', 5: '虻', 6: '蚁', 7: '思', 8: '蚂', 9: '盅', 10: '咣', 11: '虽', 12: '品',
          13: '咽', 14: '骂', 15: '哕', 16: '剐', 17: '郧', 18: '勋', 19: '咻', 20: '哗', 21: '囿', 22: '咱', 23: '咿',
          24: '响', 25: '哌', 26: '哙', 27: '哈', 28: '哚', 29: '咯', 30: '哆', 31: '咬', 32: '咳', 33: '咩', 34: '咪',
          35: '咤', 36: '哝', 37: '哪', 38: '哏', 39: '哞', 40: '哟', 41: '峙', 42: '炭', 43: '峡', 44: '峣', 45: '罘',
          46: '帧', 47: '罚', 48: '峒', 49: '峤', 50: '峋', 51: '峥', 52: '峧', 53: '帡', 54: '贱', 55: '贴', 56: '贶',
          57: '贻', 58: '骨', 59: '幽', 60: '钘', 61: '钙', 62: '钚', 63: '钛', 64: '钝', 65: '钞', 66: '钟', 67: '钡',
          68: '钠', 69: '钢', 70: '钣', 71: '钤', 72: '钥', 73: '钦', 74: '钧', 75: '钨', 76: '钩', 77: '钪', 78: '钫',
          79: '钬', 80: '钭', 81: '钮', 82: '钯', 83: '卸', 84: '缸', 85: '拜', 86: '看', 87: '矩', 88: '矧', 89: '毡',
          90: '氡', 91: '氟', 92: '氢', 93: '牯', 94: '怎', 95: '郜', 96: '牲', 97: '选', 98: '适', 99: '秕', 100: '秒',
          101: '香', 102: '种', 103: '秭', 104: '秋', 105: '科', 106: '重', 107: '复', 108: '竽', 109: '竿', 110: '笈',
          111: '笃', 112: '俦', 113: '段', 114: '俨', 115: '俅', 116: '便', 117: '俩', 118: '俪', 119: '叟', 120: '垡',
          121: '贷', 122: '牮', 123: '顺', 124: '修', 125: '俏', 126: '俣', 127: '俚', 128: '保', 129: '俜', 130: '促',
          131: '俄', 132: '俐', 133: '侮', 134: '俭', 135: '俗', 136: '俘', 137: '信', 138: '皇', 139: '泉', 140: '皈',
          141: '鬼', 142: '侵', 143: '禹', 144: '侯', 145: '追', 146: '俑', 147: '俟', 148: '俊', 149: '盾', 150: '逅',
          151: '待', 152: '徊', 153: '徇', 154: '徉', 155: '衍', 156: '律', 157: '很', 158: '须', 159: '舢', 160: '舣',
          161: '叙', 162: '俞', 163: '弇', 164: '郗', 165: '剑', 166: '逃', 167: '俎', 168: '卻', 169: '爰', 170: '郛',
          171: '食', 172: '瓴', 173: '盆', 174: '胚', 175: '胧', 176: '胨', 177: '胩', 178: '胪', 179: '胆', 180: '胛',
          181: '胂', 182: '胜', 183: '胙', 184: '胍', 185: '胗', 186: '胝', 187: '朐', 188: '胞', 189: '胖', 190: '脉',
          191: '胫', 192: '胎', 193: '鸨', 194: '匍', 195: '勉', 196: '狨', 197: '狭', 198: '狮', 199: '独', 200: '狯',
          201: '狰', 202: '狡', 203: '飐', 204: '飑', 205: '狩', 206: '狱', 207: '狠', 208: '狲', 209: '訇', 210: '訄',
          211: '逄', 212: '昝', 213: '贸', 214: '怨', 215: '急', 216: '饵', 217: '饶', 218: '蚀', 219: '饷', 220: '饸',
          221: '饹', 222: '饺', 223: '饻', 224: '胤', 225: '饼', 226: '峦', 227: '弯', 228: '孪', 229: '娈', 230: '将',
          231: '奖', 232: '哀', 233: '亭', 234: '亮', 235: '庤', 236: '度', 237: '弈', 238: '奕', 239: '迹', 240: '庭',
          241: '庥', 242: '疬', 243: '疣', 244: '疥', 245: '疭', 246: '疮', 247: '疯', 248: '疫', 249: '疢', 250: '疤',
          251: '庠', 252: '咨', 253: '姿', 254: '亲', 255: '竑'},
    138: {1: '音', 2: '彦', 3: '飒', 4: '帝', 5: '施', 6: '闺', 7: '闻', 8: '闼', 9: '闽', 10: '闾', 11: '闿', 12: '阀',
          13: '阁', 14: '阂', 15: '差', 16: '养', 17: '美', 18: '羑', 19: '姜', 20: '迸', 21: '叛', 22: '送', 23: '类',
          24: '籼', 25: '迷', 26: '籽', 27: '娄', 28: '前', 29: '酋', 30: '首', 31: '逆', 32: '兹', 33: '总', 34: '炳',
          35: '炻', 36: '炼', 37: '炟', 38: '炽', 39: '炯', 40: '炸', 41: '烀', 42: '烁', 43: '炮', 44: '炷', 45: '炫',
          46: '烂', 47: '烃', 48: '剃', 49: '洼', 50: '洁', 51: '洱', 52: '洪', 53: '洹', 54: '洒', 55: '洧', 56: '洌',
          57: '浃', 58: '柒', 59: '浇', 60: '泚', 61: '浈', 62: '浉', 63: '浊', 64: '洞', 65: '洇', 66: '洄', 67: '测',
          68: '洙', 69: '洗', 70: '活', 71: '洑', 72: '涎', 73: '洎', 74: '洫', 75: '派', 76: '浍', 77: '洽', 78: '洮',
          79: '染', 80: '洵', 81: '洚', 82: '洺', 83: '洛', 84: '浏', 85: '济', 86: '洨', 87: '浐', 88: '洋', 89: '洴',
          90: '洣', 91: '洲', 92: '浑', 93: '浒', 94: '浓', 95: '津', 96: '浔', 97: '浕', 98: '洳', 99: '恸', 100: '恃',
          101: '恒', 102: '恹', 103: '恢', 104: '恍', 105: '恫', 106: '恺', 107: '恻', 108: '恬', 109: '恤', 110: '恰',
          111: '恂', 112: '恪', 113: '恼', 114: '恽', 115: '恨', 116: '举', 117: '觉', 118: '宣', 119: '宦', 120: '宥',
          121: '宬', 122: '室', 123: '宫', 124: '宪', 125: '突', 126: '穿', 127: '窀', 128: '窃', 129: '客', 130: '诫',
          131: '冠', 132: '诬', 133: '语', 134: '扁', 135: '扃', 136: '袆', 137: '衲', 138: '衽', 139: '袄', 140: '衿',
          141: '袂', 142: '祛', 143: '祜', 144: '祓', 145: '祖', 146: '神', 147: '祝', 148: '祚', 149: '诮', 150: '祗',
          151: '祢', 152: '祠', 153: '误', 154: '诰', 155: '诱', 156: '诲', 157: '诳', 158: '鸩', 159: '说', 160: '昶',
          161: '诵', 162: '郡', 163: '垦', 164: '退', 165: '既', 166: '屋', 167: '昼', 168: '咫', 169: '屏', 170: '屎',
          171: '弭', 172: '费', 173: '陡', 174: '逊', 175: '牁', 176: '眉', 177: '胥', 178: '孩', 179: '陛', 180: '陟',
          181: '陧', 182: '陨', 183: '除', 184: '险', 185: '院', 186: '娃', 187: '姞', 188: '姥', 189: '娅', 190: '姨',
          191: '娆', 192: '姻', 193: '姝', 194: '娇', 195: '姚', 196: '姽', 197: '姣', 198: '姘', 199: '姹', 200: '娜',
          201: '怒', 202: '架', 203: '贺', 204: '盈', 205: '怼', 206: '羿', 207: '勇', 208: '炱', 209: '怠', 210: '癸',
          211: '蚤', 212: '柔', 213: '矜', 214: '垒', 215: '绑', 216: '绒', 217: '结', 218: '绔', 219: '骁', 220: '绕',
          221: '骄', 222: '骅', 223: '绗', 224: '绘', 225: '给', 226: '绚', 227: '彖', 228: '绛', 229: '络', 230: '骆',
          231: '绝', 232: '绞', 233: '骇', 234: '统', 235: '骈', 236: '耕', 237: '耘', 238: '耖', 239: '耗', 240: '耙',
          241: '艳', 242: '挈', 243: '恝', 244: '泰', 245: '秦', 246: '珥', 247: '珙', 248: '顼', 249: '珰', 250: '珠',
          251: '珽', 252: '珩', 253: '珧', 254: '珣', 255: '珞'},
    139: {1: '琤', 2: '班', 3: '珲', 4: '敖', 5: '素', 6: '匿', 7: '蚕', 8: '顽', 9: '盏', 10: '匪', 11: '恚', 12: '捞',
          13: '栽', 14: '捕', 15: '埔', 16: '埂', 17: '捂', 18: '振', 19: '载', 20: '赶', 21: '起', 22: '盐', 23: '捎',
          24: '捍', 25: '埕', 26: '捏', 27: '埘', 28: '埋', 29: '捉', 30: '捆', 31: '捐', 32: '埚', 33: '埙', 34: '损',
          35: '袁', 36: '挹', 37: '捌', 38: '都', 39: '哲', 40: '逝', 41: '耆', 42: '耄', 43: '捡', 44: '挫', 45: '捋',
          46: '埒', 47: '换', 48: '挽', 49: '贽', 50: '挚', 51: '热', 52: '恐', 53: '捣', 54: '垸', 55: '壶', 56: '捃',
          57: '捅', 58: '盍', 59: '埃', 60: '挨', 61: '耻', 62: '耿', 63: '耽', 64: '聂', 65: '莰', 66: '茝', 67: '荸',
          68: '莆', 69: '恭', 70: '莽', 71: '莱', 72: '莲', 73: '莳', 74: '莫', 75: '莴', 76: '莪', 77: '莉', 78: '莠',
          79: '莓', 80: '荷', 81: '莜', 82: '莅', 83: '荼', 84: '莶', 85: '莩', 86: '荽', 87: '获', 88: '莸', 89: '荻',
          90: '莘', 91: '晋', 92: '恶', 93: '莎', 94: '莞', 95: '莹', 96: '莨', 97: '莺', 98: '真', 99: '莙', 100: '鸪',
          101: '莼', 102: '框', 103: '梆', 104: '桂', 105: '桔', 106: '栲', 107: '栳', 108: '郴', 109: '桓', 110: '栖',
          111: '桡', 112: '桎', 113: '桢', 114: '桄', 115: '档', 116: '桐', 117: '桤', 118: '株', 119: '梃', 120: '栝',
          121: '桥', 122: '桕', 123: '桦', 124: '桁', 125: '栓', 126: '桧', 127: '桃', 128: '桅', 129: '栒', 130: '格',
          131: '桩', 132: '校', 133: '核', 134: '样', 135: '栟', 136: '桉', 137: '根', 138: '栩', 139: '逑', 140: '索',
          141: '逋', 142: '彧', 143: '哥', 144: '速', 145: '鬲', 146: '豇', 147: '逗', 148: '栗', 149: '贾', 150: '酐',
          151: '酎', 152: '酌', 153: '配', 154: '酏', 155: '逦', 156: '翅', 157: '辱', 158: '唇', 159: '厝', 160: '孬',
          161: '夏', 162: '砝', 163: '砹', 164: '砸', 165: '砺', 166: '砰', 167: '砧', 168: '砷', 169: '砟', 170: '砼',
          171: '砥', 172: '砾', 173: '砣', 174: '础', 175: '破', 176: '硁', 177: '恧', 178: '原', 179: '套', 180: '剞',
          181: '逐', 182: '砻', 183: '烈', 184: '殊', 185: '殉', 186: '顾', 187: '轼', 188: '轾', 189: '轿', 190: '辀',
          191: '辁', 192: '辂', 193: '较', 194: '鸫', 195: '顿', 196: '趸', 197: '毙', 198: '致', 199: '剕', 200: '龀',
          201: '柴', 202: '桌', 203: '鸬', 204: '虔', 205: '虑', 206: '监', 207: '紧', 208: '逍', 209: '党', 210: '眬',
          211: '唛', 212: '逞', 213: '晒', 214: '晟', 215: '眩', 216: '眠', 217: '晓', 218: '眙', 219: '唝', 220: '哧',
          221: '哳', 222: '哮', 223: '唠', 224: '鸭', 225: '晃', 226: '哺', 227: '哽', 228: '唔', 229: '晔', 230: '晌',
          231: '晁', 232: '剔', 233: '晏', 234: '晖', 235: '晕', 236: '鸮', 237: '趵', 238: '趿', 239: '畛', 240: '蚌',
          241: '蚨', 242: '蚜', 243: '蚍', 244: '蚋', 245: '蚬', 246: '畔', 247: '蚝', 248: '蚧', 249: '蚣', 250: '蚊',
          251: '蚪', 252: '蚓', 253: '哨', 254: '唢', 255: '哩'},
    140: {1: '圃', 2: '哭', 3: '圄', 4: '哦', 5: '唣', 6: '唏', 7: '恩', 8: '盎', 9: '唑', 10: '鸯', 11: '唤', 12: '唁',
          13: '哼', 14: '唧', 15: '啊', 16: '唉', 17: '唆', 18: '帱', 19: '崂', 20: '崃', 21: '罡', 22: '罢', 23: '罟',
          24: '峭', 25: '峨', 26: '峪', 27: '峰', 28: '圆', 29: '觊', 30: '峻', 31: '贼', 32: '贿', 33: '赂', 34: '赃',
          35: '赅', 36: '赆', 37: '钰', 38: '钱', 39: '钲', 40: '钳', 41: '钴', 42: '钵', 43: '钷', 44: '钹', 45: '钺',
          46: '钻', 47: '钼', 48: '钽', 49: '钾', 50: '钿', 51: '铀', 52: '铁', 53: '铂', 54: '铃', 55: '铄', 56: '铅',
          57: '铆', 58: '铈', 59: '铉', 60: '铊', 61: '铋', 62: '铌', 63: '铍', 64: '铎', 65: '眚', 66: '缺', 67: '氩',
          68: '氤', 69: '氦', 70: '氧', 71: '氨', 72: '毪', 73: '特', 74: '牺', 75: '造', 76: '乘', 77: '敌', 78: '舐',
          79: '秣', 80: '秫', 81: '秤', 82: '租', 83: '秧', 84: '积', 85: '盉', 86: '秩', 87: '称', 88: '秘', 89: '透',
          90: '笄', 91: '笕', 92: '笔', 93: '笑', 94: '笊', 95: '笫', 96: '笏', 97: '笋', 98: '笆', 99: '俸', 100: '倩',
          101: '债', 102: '俵', 103: '倻', 104: '借', 105: '偌', 106: '值', 107: '倚', 108: '俺', 109: '倾', 110: '倒',
          111: '俳', 112: '俶', 113: '倬', 114: '倏', 115: '倘', 116: '俱', 117: '倡', 118: '候', 119: '赁', 120: '恁',
          121: '倭', 122: '倪', 123: '俾', 124: '倜', 125: '隼', 126: '隽', 127: '倞', 128: '俯', 129: '倍', 130: '倦',
          131: '倓', 132: '倌', 133: '倥', 134: '臬', 135: '健', 136: '臭', 137: '射', 138: '皋', 139: '躬', 140: '息',
          141: '郫', 142: '倨', 143: '倔', 144: '衄', 145: '颀', 146: '徒', 147: '徕', 148: '徐', 149: '殷', 150: '舰',
          151: '舨', 152: '舱', 153: '般', 154: '航', 155: '舫', 156: '瓞', 157: '途', 158: '拿', 159: '釜', 160: '耸',
          161: '爹', 162: '舀', 163: '爱', 164: '豺', 165: '豹', 166: '奚', 167: '鬯', 168: '衾', 169: '鸰', 170: '颁',
          171: '颂', 172: '翁', 173: '胯', 174: '胰', 175: '胱', 176: '胴', 177: '胭', 178: '脍', 179: '脎', 180: '脆',
          181: '脂', 182: '胸', 183: '胳', 184: '脏', 185: '脐', 186: '胶', 187: '脑', 188: '胲', 189: '胼', 190: '朕',
          191: '脒', 192: '胺', 193: '脓', 194: '鸱', 195: '玺', 196: '鱽', 197: '鸲', 198: '逛', 199: '狴', 200: '狸',
          201: '狷', 202: '猁', 203: '狳', 204: '猃', 205: '狺', 206: '逖', 207: '狼', 208: '卿', 209: '狻', 210: '逢',
          211: '桀', 212: '鸵', 213: '留', 214: '袅', 215: '眢', 216: '鸳', 217: '皱', 218: '饽', 219: '饿', 220: '馀',
          221: '馁', 222: '凌', 223: '凇', 224: '凄', 225: '栾', 226: '挛', 227: '恋', 228: '桨', 229: '浆', 230: '衰',
          231: '勍', 232: '衷', 233: '高', 234: '亳', 235: '郭', 236: '席', 237: '准', 238: '座', 239: '脊', 240: '症',
          241: '疳', 242: '疴', 243: '病', 244: '疽', 245: '疸', 246: '疾', 247: '痄', 248: '斋', 249: '疹', 250: '痈',
          251: '疼', 252: '疱', 253: '疰', 254: '痃', 255: '痂'},
    141: {1: '疲', 2: '痉', 3: '效', 4: '离', 5: '衮', 6: '紊', 7: '唐', 8: '凋', 9: '颃', 10: '瓷', 11: '资', 12: '恣',
          13: '凉', 14: '站', 15: '剖', 16: '竞', 17: '部', 18: '旁', 19: '旆', 20: '旄', 21: '旅', 22: '旃', 23: '畜',
          24: '阃', 25: '阄', 26: '阅', 27: '阆', 28: '羞', 29: '羔', 30: '恙', 31: '瓶', 32: '桊', 33: '拳', 34: '敉',
          35: '粉', 36: '料', 37: '粑', 38: '益', 39: '兼', 40: '朔', 41: '郸', 42: '烤', 43: '烘', 44: '烜', 45: '烦',
          46: '烧', 47: '烛', 48: '烟', 49: '烨', 50: '烩', 51: '烙', 52: '烊', 53: '剡', 54: '郯', 55: '烬', 56: '递',
          57: '涛', 58: '浙', 59: '涝', 60: '浡', 61: '浦', 62: '涑', 63: '浯', 64: '酒', 65: '涞', 66: '涟', 67: '涉',
          68: '娑', 69: '消', 70: '涅', 71: '涠', 72: '浞', 73: '涓', 74: '涢', 75: '涡', 76: '浥', 77: '涔', 78: '浩',
          79: '海', 80: '浜', 81: '涂', 82: '浠', 83: '浴', 84: '浮', 85: '涣', 86: '浼', 87: '涤', 88: '流', 89: '润',
          90: '涧', 91: '涕', 92: '浣', 93: '浪', 94: '浸', 95: '涨', 96: '烫', 97: '涩', 98: '涌', 99: '涘', 100: '浚',
          101: '悖', 102: '悚', 103: '悟', 104: '悭', 105: '悄', 106: '悍', 107: '悝', 108: '悃', 109: '悒', 110: '悔',
          111: '悯', 112: '悦', 113: '悌', 114: '悢', 115: '悛', 116: '害', 117: '宽', 118: '宸', 119: '家', 120: '宵',
          121: '宴', 122: '宾', 123: '窍', 124: '窅', 125: '窄', 126: '容', 127: '窈', 128: '剜', 129: '宰', 130: '案',
          131: '请', 132: '朗', 133: '诸', 134: '诹', 135: '诺', 136: '读', 137: '扅', 138: '诼', 139: '冢', 140: '扇',
          141: '诽', 142: '袜', 143: '袪', 144: '袒', 145: '袖', 146: '袗', 147: '袍', 148: '袢', 149: '被', 150: '袯',
          151: '祯', 152: '祧', 153: '祥', 154: '课', 155: '冥', 156: '诿', 157: '谀', 158: '谁', 159: '谂', 160: '调',
          161: '冤', 162: '谄', 163: '谅', 164: '谆', 165: '谇', 166: '谈', 167: '谊', 168: '剥', 169: '恳', 170: '展',
          171: '剧', 172: '屑', 173: '屐', 174: '屙', 175: '弱', 176: '陵', 177: '陬', 178: '勐', 179: '奘', 180: '疍',
          181: '牂', 182: '蚩', 183: '祟', 184: '陲', 185: '陴', 186: '陶', 187: '陷', 188: '陪', 189: '烝', 190: '姬',
          191: '娠', 192: '娱', 193: '娌', 194: '娉', 195: '娟', 196: '娲', 197: '恕', 198: '娥', 199: '娩', 200: '娴',
          201: '娣', 202: '娘', 203: '娓', 204: '婀', 205: '砮', 206: '哿', 207: '畚', 208: '通', 209: '能', 210: '难',
          211: '逡', 212: '预', 213: '桑', 214: '剟', 215: '绠', 216: '骊', 217: '绡', 218: '骋', 219: '绢', 220: '绣',
          221: '验', 222: '绤', 223: '绥', 224: '绦', 225: '骍', 226: '继', 227: '绨', 228: '骎', 229: '骏', 230: '邕',
          231: '鸶', 232: '彗', 233: '耜', 234: '焘', 235: '舂', 236: '琎', 237: '球', 238: '琏', 239: '琐', 240: '理',
          241: '琇', 242: '麸', 243: '琉', 244: '琅', 245: '捧', 246: '掭', 247: '堵', 248: '揶', 249: '措', 250: '描',
          251: '埴', 252: '域', 253: '捺', 254: '掎', 255: '埼'},
    142: {1: '掩', 2: '埯', 3: '捷', 4: '捯', 5: '排', 6: '焉', 7: '掉', 8: '掳', 9: '掴', 10: '埸', 11: '堌', 12: '捶',
          13: '赦', 14: '赧', 15: '推', 16: '堆', 17: '捭', 18: '埠', 19: '晢', 20: '掀', 21: '逵', 22: '授', 23: '捻',
          24: '埝', 25: '堋', 26: '教', 27: '堍', 28: '掏', 29: '掐', 30: '掬', 31: '鸷', 32: '掠', 33: '掂', 34: '掖',
          35: '培', 36: '掊', 37: '接', 38: '堉', 39: '掷', 40: '掸', 41: '控', 42: '捩', 43: '掮', 44: '探', 45: '悫',
          46: '埭', 47: '埽', 48: '据', 49: '掘', 50: '掺', 51: '掇', 52: '掼', 53: '职', 54: '聃', 55: '基', 56: '聆',
          57: '勘', 58: '聊', 59: '聍', 60: '娶', 61: '菁', 62: '菝', 63: '著', 64: '菱', 65: '萁', 66: '菥', 67: '菘',
          68: '堇', 69: '勒', 70: '黄', 71: '萘', 72: '萋', 73: '勩', 74: '菲', 75: '菽', 76: '菖', 77: '萌', 78: '萜',
          79: '萝', 80: '菌', 81: '萎', 82: '萸', 83: '萑', 84: '菂', 85: '菜', 86: '棻', 87: '菔', 88: '菟', 89: '萄',
          90: '萏', 91: '菊', 92: '萃', 93: '菩', 94: '菼', 95: '菏', 96: '萍', 97: '菹', 98: '菠', 99: '菪', 100: '菅',
          101: '菀', 102: '萤', 103: '营', 104: '萦', 105: '乾', 106: '萧', 107: '菰', 108: '菡', 109: '萨', 110: '菇',
          111: '械', 112: '梽', 113: '彬', 114: '梵', 115: '梦', 116: '婪', 117: '梗', 118: '梧', 119: '梾', 120: '梢',
          121: '梏', 122: '梅', 123: '觋', 124: '检', 125: '桴', 126: '桷', 127: '梓', 128: '梳', 129: '棁', 130: '梯',
          131: '桫', 132: '棂', 133: '桶', 134: '梭', 135: '救', 136: '啬', 137: '郾', 138: '匮', 139: '曹', 140: '敕',
          141: '副', 142: '豉', 143: '票', 144: '鄄', 145: '酝', 146: '酞', 147: '酗', 148: '酚', 149: '厢', 150: '厣',
          151: '戚', 152: '戛', 153: '硎', 154: '硅', 155: '硭', 156: '硒', 157: '硕', 158: '硖', 159: '硗', 160: '硐',
          161: '硚', 162: '硇', 163: '硌', 164: '鸸', 165: '瓠', 166: '匏', 167: '奢', 168: '盔', 169: '爽', 170: '厩',
          171: '聋', 172: '龚', 173: '袭', 174: '殒', 175: '殓', 176: '殍', 177: '盛', 178: '赉', 179: '匾', 180: '雩',
          181: '雪', 182: '辄', 183: '辅', 184: '辆', 185: '堑', 186: '龁', 187: '颅', 188: '虚', 189: '彪', 190: '雀',
          191: '堂', 192: '常', 193: '眶', 194: '眭', 195: '唪', 196: '眦', 197: '啧', 198: '匙', 199: '晡', 200: '晤',
          201: '晨', 202: '眺', 203: '眵', 204: '睁', 205: '眯', 206: '眼', 207: '眸', 208: '悬', 209: '野', 210: '圊',
          211: '啪', 212: '啦', 213: '喏', 214: '喵', 215: '啉', 216: '勖', 217: '曼', 218: '晦', 219: '晞', 220: '晗',
          221: '晚', 222: '冕', 223: '啄', 224: '啭', 225: '啡', 226: '畦', 227: '趼', 228: '趺', 229: '距', 230: '趾',
          231: '啃', 232: '跃', 233: '啮', 234: '跄', 235: '略', 236: '蚶', 237: '蛄', 238: '蛎', 239: '蛆', 240: '蚰',
          241: '蚺', 242: '蛊', 243: '圉', 244: '蚱', 245: '蚯', 246: '蛉', 247: '蛀', 248: '蛇', 249: '蛏', 250: '蚴',
          251: '唬', 252: '累', 253: '鄂', 254: '唱', 255: '患'},
    143: {1: '啰', 2: '唾', 3: '唯', 4: '啤', 5: '啥', 6: '啁', 7: '啕', 8: '唿', 9: '啐', 10: '唼', 11: '唷', 12: '啴',
          13: '啖', 14: '啵', 15: '啶', 16: '啷', 17: '唳', 18: '啸', 19: '啜', 20: '帻', 21: '崖', 22: '崎', 23: '崦',
          24: '崭', 25: '逻', 26: '帼', 27: '崮', 28: '崔', 29: '帷', 30: '崟', 31: '崤', 32: '崩', 33: '崞', 34: '崇',
          35: '崆', 36: '崛', 37: '赇', 38: '赈', 39: '婴', 40: '赊', 41: '圈', 42: '铐', 43: '铑', 44: '铒', 45: '铕',
          46: '铗', 47: '铘', 48: '铙', 49: '铚', 50: '铛', 51: '铜', 52: '铝', 53: '铞', 54: '铟', 55: '铠', 56: '铡',
          57: '铢', 58: '铣', 59: '铤', 60: '铥', 61: '铧', 62: '铨', 63: '铩', 64: '铪', 65: '铫', 66: '铭', 67: '铬',
          68: '铮', 69: '铯', 70: '铰', 71: '铱', 72: '铲', 73: '铳', 74: '铴', 75: '铵', 76: '银', 77: '铷', 78: '矫',
          79: '氪', 80: '牾', 81: '甜', 82: '鸹', 83: '秸', 84: '梨', 85: '犁', 86: '稆', 87: '秽', 88: '移', 89: '秾',
          90: '逶', 91: '笺', 92: '筇', 93: '笨', 94: '笸', 95: '笼', 96: '笪', 97: '笛', 98: '笙', 99: '笮', 100: '符',
          101: '笱', 102: '笠', 103: '笥', 104: '第', 105: '笳', 106: '笤', 107: '笾', 108: '笞', 109: '敏', 110: '偾',
          111: '做', 112: '鸺', 113: '偃', 114: '偕', 115: '袋', 116: '悠', 117: '偿', 118: '偶', 119: '偈', 120: '偎',
          121: '偲', 122: '傀', 123: '偷', 124: '您', 125: '偬', 126: '售', 127: '停', 128: '偻', 129: '偏', 130: '躯',
          131: '皑', 132: '兜', 133: '皎', 134: '假', 135: '衅', 136: '鸻', 137: '徘', 138: '徙', 139: '徜', 140: '得',
          141: '衔', 142: '舸', 143: '舻', 144: '舳', 145: '盘', 146: '舴', 147: '舶', 148: '船', 149: '鸼', 150: '舷',
          151: '舵', 152: '斜', 153: '龛', 154: '盒', 155: '鸽', 156: '瓻', 157: '敛', 158: '悉', 159: '欲', 160: '彩',
          161: '领', 162: '翎', 163: '脚', 164: '脖', 165: '脯', 166: '豚', 167: '脶', 168: '脸', 169: '脞', 170: '脬',
          171: '脱', 172: '脘', 173: '脲', 174: '脧', 175: '匐', 176: '鱾', 177: '象', 178: '够', 179: '逸', 180: '猜',
          181: '猪', 182: '猎', 183: '猫', 184: '猗', 185: '凰', 186: '猖', 187: '猡', 188: '猊', 189: '猞', 190: '猄',
          191: '猝', 192: '斛', 193: '觖', 194: '猕', 195: '猛', 196: '馗', 197: '祭', 198: '馃', 199: '馄', 200: '馅',
          201: '馆', 202: '凑', 203: '减', 204: '鸾', 205: '毫', 206: '孰', 207: '烹', 208: '庶', 209: '庹', 210: '麻',
          211: '庵', 212: '庼', 213: '庾', 214: '庳', 215: '痔', 216: '痍', 217: '疵', 218: '痊', 219: '痒', 220: '痕',
          221: '廊', 222: '康', 223: '庸', 224: '鹿', 225: '盗', 226: '章', 227: '竟', 228: '翊', 229: '商', 230: '旌',
          231: '族', 232: '旎', 233: '旋', 234: '望', 235: '袤', 236: '率', 237: '阇', 238: '阈', 239: '阉', 240: '阊',
          241: '阋', 242: '阌', 243: '阍', 244: '阎', 245: '阏', 246: '阐', 247: '着', 248: '羚', 249: '羝', 250: '羟',
          251: '盖', 252: '眷', 253: '粝', 254: '粘', 255: '粗'},
    144: {1: '粕', 2: '粒', 3: '断', 4: '剪', 5: '兽', 6: '焐', 7: '焊', 8: '烯', 9: '焓', 10: '焕', 11: '烽', 12: '焖',
          13: '烷', 14: '烺', 15: '焌', 16: '清', 17: '渍', 18: '添', 19: '渚', 20: '鸿', 21: '淇', 22: '淋', 23: '淅',
          24: '淞', 25: '渎', 26: '涯', 27: '淹', 28: '涿', 29: '渠', 30: '渐', 31: '淑', 32: '淖', 33: '挲', 34: '淌',
          35: '淏', 36: '混', 37: '淠', 38: '涸', 39: '渑', 40: '淮', 41: '淦', 42: '淆', 43: '渊', 44: '淫', 45: '淝',
          46: '渔', 47: '淘', 48: '淳', 49: '液', 50: '淬', 51: '涪', 52: '淤', 53: '淡', 54: '淙', 55: '淀', 56: '涫',
          57: '深', 58: '渌', 59: '涮', 60: '涵', 61: '婆', 62: '梁', 63: '渗', 64: '淄', 65: '情', 66: '惬', 67: '悻',
          68: '惜', 69: '惭', 70: '悱', 71: '悼', 72: '惝', 73: '惧', 74: '惕', 75: '惘', 76: '悸', 77: '惟', 78: '惆',
          79: '惚', 80: '惊', 81: '惇', 82: '惦', 83: '悴', 84: '惮', 85: '惋', 86: '惨', 87: '惯', 88: '寇', 89: '寅',
          90: '寄', 91: '寂', 92: '逭', 93: '宿', 94: '窒', 95: '窑', 96: '窕', 97: '密', 98: '谋', 99: '谌', 100: '谍',
          101: '谎', 102: '谏', 103: '扈', 104: '皲', 105: '谐', 106: '谑', 107: '裆', 108: '袱', 109: '袼', 110: '裈',
          111: '裉', 112: '祷', 113: '祸', 114: '祲', 115: '谒', 116: '谓', 117: '谔', 118: '谕', 119: '谖', 120: '谗',
          121: '谙', 122: '谚', 123: '谛', 124: '谜', 125: '谝', 126: '敝', 127: '逮', 128: '逯', 129: '敢', 130: '尉',
          131: '屠', 132: '艴', 133: '弹', 134: '隋', 135: '堕', 136: '郿', 137: '随', 138: '蛋', 139: '隅', 140: '隈',
          141: '粜', 142: '隍', 143: '隗', 144: '隆', 145: '隐', 146: '婧', 147: '婊', 148: '婞', 149: '婳', 150: '婕',
          151: '娼', 152: '婢', 153: '婚', 154: '婵', 155: '婶', 156: '婉', 157: '胬', 158: '袈', 159: '颇', 160: '颈',
          161: '翌', 162: '恿', 163: '欸', 164: '绩', 165: '绪', 166: '绫', 167: '骐', 168: '续', 169: '骑', 170: '绮',
          171: '绯', 172: '绰', 173: '骒', 174: '绲', 175: '绳', 176: '骓', 177: '维', 178: '绵', 179: '绶', 180: '绷',
          181: '绸', 182: '绹', 183: '绺', 184: '绻', 185: '综', 186: '绽', 187: '绾', 188: '绿', 189: '骖', 190: '缀',
          191: '缁', 192: '巢', 193: '耠', 194: '琫', 195: '琵', 196: '琴', 197: '琶', 198: '琪', 199: '瑛', 200: '琳',
          201: '琦', 202: '琢', 203: '琥', 204: '琨', 205: '靓', 206: '琼', 207: '斑', 208: '琰', 209: '琮', 210: '琯',
          211: '琬', 212: '琛', 213: '琚', 214: '辇', 215: '替', 216: '鼋', 217: '揳', 218: '揍', 219: '款', 220: '堪',
          221: '堞', 222: '搽', 223: '塔', 224: '搭', 225: '塃', 226: '揸', 227: '堰', 228: '揠', 229: '堙', 230: '揩',
          231: '越', 232: '趄', 233: '趁', 234: '趋', 235: '超', 236: '揽', 237: '提', 238: '堤', 239: '揖', 240: '博',
          241: '揾', 242: '颉', 243: '揭', 244: '喜', 245: '彭', 246: '揣', 247: '塄', 248: '揿', 249: '插', 250: '揪',
          251: '搜', 252: '煮', 253: '堠', 254: '耋', 255: '揄'},
    145: {1: '援', 2: '搀', 3: '蛰', 4: '蛩', 5: '絷', 6: '塆', 7: '裁', 8: '揞', 9: '搁', 10: '搓', 11: '搂', 12: '搅',
          13: '揎', 14: '壹', 15: '握', 16: '摒', 17: '揆', 18: '搔', 19: '揉', 20: '掾', 21: '葜', 22: '聒', 23: '斯',
          24: '期', 25: '欺', 26: '联', 27: '葑', 28: '葚', 29: '葫', 30: '靰', 31: '靸', 32: '散', 33: '葳', 34: '惹',
          35: '蒇', 36: '葬', 37: '蒈', 38: '募', 39: '葺', 40: '葛', 41: '蒉', 42: '葸', 43: '萼', 44: '蓇', 45: '萩',
          46: '董', 47: '葆', 48: '葩', 49: '葡', 50: '敬', 51: '葱', 52: '蒋', 53: '葶', 54: '蒂', 55: '蒌', 56: '葓',
          57: '蒎', 58: '落', 59: '萱', 60: '葖', 61: '韩', 62: '戟', 63: '朝', 64: '葭', 65: '辜', 66: '葵', 67: '棒',
          68: '楮', 69: '棱', 70: '棋', 71: '椰', 72: '植', 73: '森', 74: '棼', 75: '焚', 76: '椟', 77: '椅', 78: '椒',
          79: '棹', 80: '棵', 81: '棍', 82: '椤', 83: '棰', 84: '椎', 85: '棉', 86: '椑', 87: '鹀', 88: '赍', 89: '棚',
          90: '椋', 91: '椁', 92: '棬', 93: '棕', 94: '棺', 95: '榔', 96: '楗', 97: '棣', 98: '椐', 99: '椭', 100: '鹁',
          101: '惠', 102: '惑', 103: '逼', 104: '覃', 105: '粟', 106: '棘', 107: '酣', 108: '酤', 109: '酢', 110: '酥',
          111: '酡', 112: '酦', 113: '鹂', 114: '觌', 115: '厨', 116: '厦', 117: '硬', 118: '硝', 119: '硪', 120: '硷',
          121: '确', 122: '硫', 123: '雁', 124: '厥', 125: '殖', 126: '裂', 127: '雄', 128: '殚', 129: '殛', 130: '颊',
          131: '雳', 132: '雯', 133: '辊', 134: '辋', 135: '椠', 136: '暂', 137: '辌', 138: '辍', 139: '辎', 140: '雅',
          141: '翘', 142: '辈', 143: '斐', 144: '悲', 145: '紫', 146: '黹', 147: '辉', 148: '敞', 149: '棠', 150: '牚',
          151: '赏', 152: '掌', 153: '晴', 154: '睐', 155: '暑', 156: '最', 157: '晰', 158: '量', 159: '睑', 160: '睇',
          161: '鼎', 162: '睃', 163: '喷', 164: '戢', 165: '喋', 166: '嗒', 167: '喃', 168: '喳', 169: '晶', 170: '喇',
          171: '遇', 172: '喊', 173: '喱', 174: '喹', 175: '遏', 176: '晷', 177: '晾', 178: '景', 179: '喈', 180: '畴',
          181: '践', 182: '跖', 183: '跋', 184: '跌', 185: '跗', 186: '跞', 187: '跚', 188: '跑', 189: '跎', 190: '跏',
          191: '跛', 192: '跆', 193: '遗', 194: '蛙', 195: '蛱', 196: '蛲', 197: '蛭', 198: '蛳', 199: '蛐', 200: '蛔',
          201: '蛛', 202: '蜓', 203: '蛞', 204: '蜒', 205: '蛤', 206: '蛴', 207: '蛟', 208: '蛘', 209: '蛑', 210: '畯',
          211: '喁', 212: '喝', 213: '鹃', 214: '喂', 215: '喟', 216: '斝', 217: '喘', 218: '啾', 219: '嗖', 220: '喤',
          221: '喉', 222: '喻', 223: '喑', 224: '啼', 225: '嗟', 226: '喽', 227: '嗞', 228: '喧', 229: '喀', 230: '喔',
          231: '喙', 232: '嵌', 233: '嵘', 234: '嵖', 235: '幅', 236: '崴', 237: '遄', 238: '詈', 239: '帽', 240: '嵎',
          241: '崽', 242: '嵚', 243: '嵬', 244: '嵛', 245: '翙', 246: '嵯', 247: '嵝', 248: '嵫', 249: '幄', 250: '嵋',
          251: '赋', 252: '赌', 253: '赎', 254: '赐', 255: '赑'},
    146: {1: '赔', 2: '黑', 3: '铸', 4: '铹', 5: '铺', 6: '铻', 7: '铼', 8: '铽', 9: '链', 10: '铿', 11: '销', 12: '锁',
          13: '锃', 14: '锄', 15: '锂', 16: '锅', 17: '锆', 18: '锇', 19: '锈', 20: '锉', 21: '锊', 22: '锋', 23: '锌',
          24: '锎', 25: '锏', 26: '锐', 27: '锑', 28: '锒', 29: '锓', 30: '锔', 31: '锕', 32: '甥', 33: '掣', 34: '掰',
          35: '短', 36: '智', 37: '矬', 38: '氰', 39: '毳', 40: '毯', 41: '氮', 42: '毽', 43: '氯', 44: '犊', 45: '犄',
          46: '犋', 47: '鹄', 48: '犍', 49: '鹅', 50: '颋', 51: '剩', 52: '嵇', 53: '稍', 54: '程', 55: '稀', 56: '黍',
          57: '稃', 58: '税', 59: '稂', 60: '筐', 61: '等', 62: '筘', 63: '筑', 64: '策', 65: '筚', 66: '筛', 67: '筜',
          68: '筒', 69: '筅', 70: '筏', 71: '筵', 72: '筌', 73: '答', 74: '筋', 75: '筝', 76: '傣', 77: '傲', 78: '傅',
          79: '傈', 80: '舄', 81: '牍', 82: '牌', 83: '傥', 84: '堡', 85: '集', 86: '焦', 87: '傍', 88: '傧', 89: '储',
          90: '遑', 91: '皓', 92: '皖', 93: '粤', 94: '奥', 95: '傩', 96: '遁', 97: '街', 98: '惩', 99: '御', 100: '徨',
          101: '循', 102: '舾', 103: '艇', 104: '舒', 105: '畲', 106: '弑', 107: '逾', 108: '颌', 109: '翕', 110: '釉',
          111: '番', 112: '释', 113: '鹆', 114: '禽', 115: '舜', 116: '貂', 117: '腈', 118: '腊', 119: '腌', 120: '腓',
          121: '腆', 122: '腴', 123: '脾', 124: '腋', 125: '腑', 126: '腙', 127: '腚', 128: '腔', 129: '腕', 130: '腱',
          131: '腒', 132: '鱿', 133: '鲀', 134: '鲁', 135: '鲂', 136: '鲃', 137: '颍', 138: '猢', 139: '猹', 140: '猩',
          141: '猥', 142: '猬', 143: '猾', 144: '猴', 145: '飓', 146: '觞', 147: '觚', 148: '猸', 149: '猱', 150: '惫',
          151: '飧', 152: '然', 153: '馇', 154: '馈', 155: '馉', 156: '馊', 157: '馋', 158: '亵', 159: '装', 160: '蛮',
          161: '脔', 162: '就', 163: '敦', 164: '裒', 165: '廋', 166: '斌', 167: '痣', 168: '痨', 169: '痦', 170: '痘',
          171: '痞', 172: '痢', 173: '痤', 174: '痪', 175: '痫', 176: '痧', 177: '痛', 178: '鄌', 179: '赓', 180: '竦',
          181: '童', 182: '瓿', 183: '竣', 184: '啻', 185: '颏', 186: '鹇', 187: '阑', 188: '阒', 189: '阔', 190: '阕',
          191: '善', 192: '翔', 193: '羡', 194: '普', 195: '粪', 196: '粞', 197: '尊', 198: '奠', 199: '遒', 200: '道',
          201: '遂', 202: '孳', 203: '曾', 204: '焯', 205: '焜', 206: '焰', 207: '焙', 208: '焱', 209: '鹈', 210: '湛',
          211: '港', 212: '渫', 213: '滞', 214: '湖', 215: '湘', 216: '渣', 217: '渤', 218: '湮', 219: '湎', 220: '湝',
          221: '湨', 222: '湜', 223: '渺', 224: '湿', 225: '温', 226: '渴', 227: '渭', 228: '溃', 229: '湍', 230: '溅',
          231: '滑', 232: '湃', 233: '湫', 234: '溲', 235: '湟', 236: '溆', 237: '渝', 238: '湲', 239: '湾', 240: '渡',
          241: '游', 242: '溠', 243: '溇', 244: '湔', 245: '滋', 246: '湉', 247: '渲', 248: '溉', 249: '渥', 250: '湄',
          251: '滁', 252: '愤', 253: '慌', 254: '惰', 255: '愠'},
    147: {1: '惺', 2: '愦', 3: '愕', 4: '惴', 5: '愣', 6: '愀', 7: '愎', 8: '惶', 9: '愧', 10: '愉', 11: '愔', 12: '慨',
          13: '喾', 14: '割', 15: '寒', 16: '富', 17: '寓', 18: '窜', 19: '窝', 20: '窖', 21: '窗', 22: '窘', 23: '寐',
          24: '谟', 25: '扉', 26: '遍', 27: '棨', 28: '雇', 29: '扊', 30: '裢', 31: '裎', 32: '裣', 33: '裕', 34: '裤',
          35: '裥', 36: '裙', 37: '祾', 38: '祺', 39: '祼', 40: '谠', 41: '禅', 42: '禄', 43: '幂', 44: '谡', 45: '谢',
          46: '谣', 47: '谤', 48: '谥', 49: '谦', 50: '谧', 51: '塈', 52: '遐', 53: '犀', 54: '属', 55: '屡', 56: '孱',
          57: '弼', 58: '强', 59: '粥', 60: '巽', 61: '疏', 62: '隔', 63: '骘', 64: '隙', 65: '隘', 66: '媒', 67: '媪',
          68: '絮', 69: '嫂', 70: '媛', 71: '婷', 72: '媚', 73: '婿', 74: '巯', 75: '毵', 76: '翚', 77: '登', 78: '皴',
          79: '婺', 80: '骛', 81: '缂', 82: '缃', 83: '缄', 84: '缅', 85: '彘', 86: '缆', 87: '缇', 88: '缈', 89: '缉',
          90: '缌', 91: '缎', 92: '缏', 93: '缑', 94: '缒', 95: '缓', 96: '缔', 97: '缕', 98: '骗', 99: '编', 100: '缗',
          101: '骙', 102: '骚', 103: '缘', 104: '飨', 105: '耢', 106: '瑟', 107: '瑚', 108: '鹉', 109: '瑁', 110: '瑞',
          111: '瑰', 112: '瑀', 113: '瑜', 114: '瑗', 115: '瑄', 116: '瑕', 117: '遨', 118: '骜', 119: '瑙', 120: '遘',
          121: '韫', 122: '魂', 123: '髡', 124: '肆', 125: '摄', 126: '摸', 127: '填', 128: '搏', 129: '塥', 130: '塬',
          131: '鄢', 132: '趔', 133: '趑', 134: '摅', 135: '塌', 136: '摁', 137: '鼓', 138: '摆', 139: '赪', 140: '携',
          141: '塮', 142: '蜇', 143: '搋', 144: '搬', 145: '摇', 146: '搞', 147: '搪', 148: '塘', 149: '搒', 150: '搐',
          151: '搛', 152: '搠', 153: '摈', 154: '彀', 155: '毂', 156: '搌', 157: '搦', 158: '摊', 159: '搡', 160: '聘',
          161: '蓁', 162: '戡', 163: '斟', 164: '蒜', 165: '蓍', 166: '鄞', 167: '勤', 168: '靴', 169: '靳', 170: '靶',
          171: '鹊', 172: '蓐', 173: '蓝', 174: '墓', 175: '幕', 176: '蓦', 177: '鹋', 178: '蒽', 179: '蓓', 180: '蓖',
          181: '蓊', 182: '蒯', 183: '蓟', 184: '蓬', 185: '蓑', 186: '蒿', 187: '蒺', 188: '蓠', 189: '蒟', 190: '蒡',
          191: '蓄', 192: '蒹', 193: '蒴', 194: '蒲', 195: '蒗', 196: '蓉', 197: '蒙', 198: '蓂', 199: '蓥', 200: '颐',
          201: '蒸', 202: '献', 203: '蓣', 204: '楔', 205: '椿', 206: '楠', 207: '禁', 208: '楂', 209: '楚', 210: '楝',
          211: '楷', 212: '榄', 213: '想', 214: '楫', 215: '榀', 216: '楞', 217: '楸', 218: '椴', 219: '槐', 220: '槌',
          221: '楯', 222: '榆', 223: '榇', 224: '榈', 225: '槎', 226: '楼', 227: '榉', 228: '楦', 229: '概', 230: '楣',
          231: '楹', 232: '椽', 233: '裘', 234: '赖', 235: '剽', 236: '甄', 237: '酮', 238: '酰', 239: '酯', 240: '酪',
          241: '酩', 242: '酬', 243: '蜃', 244: '感', 245: '碛', 246: '碍', 247: '碘', 248: '碓', 249: '碑', 250: '硼',
          251: '碉', 252: '碎', 253: '碚', 254: '碰', 255: '碇'},
    148: {1: '碗', 2: '碌', 3: '碜', 4: '鹌', 5: '尴', 6: '雷', 7: '零', 8: '雾', 9: '雹', 10: '辏', 11: '辐', 12: '辑',
          13: '辒', 14: '输', 15: '督', 16: '频', 17: '龃', 18: '龄', 19: '龅', 20: '龆', 21: '觜', 22: '訾', 23: '粲',
          24: '虞', 25: '鉴', 26: '睛', 27: '睹', 28: '睦', 29: '瞄', 30: '睚', 31: '嗪', 32: '睫', 33: '韪', 34: '嗷',
          35: '嗉', 36: '睡', 37: '睨', 38: '睢', 39: '雎', 40: '睥', 41: '睬', 42: '嘟', 43: '嗜', 44: '嗑', 45: '嗫',
          46: '嗬', 47: '嗔', 48: '鄙', 49: '嗦', 50: '嗝', 51: '愚', 52: '戥', 53: '嗄', 54: '暖', 55: '盟', 56: '煦',
          57: '歇', 58: '暗', 59: '暅', 60: '暄', 61: '暇', 62: '照', 63: '遢', 64: '暌', 65: '畸', 66: '跬', 67: '跨',
          68: '跶', 69: '跷', 70: '跸', 71: '跐', 72: '跣', 73: '跹', 74: '跳', 75: '跺', 76: '跪', 77: '路', 78: '跻',
          79: '跤', 80: '跟', 81: '遣', 82: '蛸', 83: '蜈', 84: '蜎', 85: '蜗', 86: '蛾', 87: '蜊', 88: '蜍', 89: '蜉',
          90: '蜂', 91: '蜣', 92: '蜕', 93: '畹', 94: '蛹', 95: '嗣', 96: '嗯', 97: '嗅', 98: '嗥', 99: '嗲', 100: '嗳',
          101: '嗡', 102: '嗌', 103: '嗍', 104: '嗨', 105: '嗤', 106: '嗵', 107: '嗓', 108: '署', 109: '置', 110: '罨',
          111: '罪', 112: '罩', 113: '蜀', 114: '幌', 115: '嵊', 116: '嵩', 117: '嵴', 118: '骰', 119: '锖', 120: '锗',
          121: '错', 122: '锘', 123: '锚', 124: '锛', 125: '锜', 126: '锝', 127: '锞', 128: '锟', 129: '锡', 130: '锢',
          131: '锣', 132: '锤', 133: '锥', 134: '锦', 135: '锧', 136: '锨', 137: '锪', 138: '锫', 139: '锩', 140: '锬',
          141: '锭', 142: '键', 143: '锯', 144: '锰', 145: '锱', 146: '矮', 147: '雉', 148: '氲', 149: '犏', 150: '辞',
          151: '歃', 152: '稞', 153: '稚', 154: '稗', 155: '稔', 156: '稠', 157: '颓', 158: '愁', 159: '筹', 160: '筠',
          161: '筢', 162: '筮', 163: '筻', 164: '筲', 165: '筼', 166: '筱', 167: '签', 168: '简', 169: '筷', 170: '毁',
          171: '舅', 172: '鼠', 173: '牒', 174: '煲', 175: '催', 176: '傻', 177: '像', 178: '躲', 179: '鹎', 180: '魁',
          181: '敫', 182: '僇', 183: '衙', 184: '微', 185: '徭', 186: '愆', 187: '艄', 188: '觎', 189: '毹', 190: '愈',
          191: '遥', 192: '貊', 193: '貅', 194: '貉', 195: '颔', 196: '腻', 197: '腠', 198: '腩', 199: '腰', 200: '腼',
          201: '腽', 202: '腥', 203: '腮', 204: '腭', 205: '腹', 206: '腺', 207: '腧', 208: '鹏', 209: '塍', 210: '媵',
          211: '腾', 212: '腿', 213: '詹', 214: '鲅', 215: '鲆', 216: '鲇', 217: '鲈', 218: '鲉', 219: '鲊', 220: '稣',
          221: '鲋', 222: '鲌', 223: '鲍', 224: '鲏', 225: '鲐', 226: '肄', 227: '猿', 228: '颖', 229: '鹐', 230: '飔',
          231: '飕', 232: '觥', 233: '触', 234: '解', 235: '遛', 236: '煞', 237: '雏', 238: '馌', 239: '馍', 240: '馏',
          241: '馐', 242: '酱', 243: '鹑', 244: '禀', 245: '亶', 246: '廒', 247: '瘃', 248: '痱', 249: '痹', 250: '痼',
          251: '廓', 252: '痴', 253: '痿', 254: '瘐', 255: '瘁'},
    149: {1: '瘅', 2: '痰', 3: '瘆', 4: '廉', 5: '鄘', 6: '麂', 7: '裔', 8: '靖', 9: '新', 10: '鄣', 11: '歆', 12: '韵',
          13: '意', 14: '旒', 15: '雍', 16: '阖', 17: '阗', 18: '阘', 19: '阙', 20: '羧', 21: '豢', 22: '誊', 23: '粳',
          24: '粮', 25: '数', 26: '煎', 27: '猷', 28: '塑', 29: '慈', 30: '煤', 31: '煳', 32: '煜', 33: '煨', 34: '煅',
          35: '煌', 36: '煊', 37: '煸', 38: '煺', 39: '滟', 40: '溱', 41: '溘', 42: '滠', 43: '满', 44: '漭', 45: '漠',
          46: '滢', 47: '滇', 48: '溥', 49: '溧', 50: '溽', 51: '源', 52: '滤', 53: '滥', 54: '裟', 55: '溻', 56: '溷',
          57: '溦', 58: '滗', 59: '滫', 60: '溴', 61: '滏', 62: '滔', 63: '溪', 64: '滃', 65: '溜', 66: '滦', 67: '漓',
          68: '滚', 69: '溏', 70: '滂', 71: '溢', 72: '溯', 73: '滨', 74: '溶', 75: '滓', 76: '溟', 77: '滘', 78: '溺',
          79: '滍', 80: '粱', 81: '滩', 82: '滪', 83: '愫', 84: '慑', 85: '慎', 86: '慥', 87: '慊', 88: '誉', 89: '鲎',
          90: '塞', 91: '骞', 92: '寞', 93: '窥', 94: '窦', 95: '窠', 96: '窣', 97: '窟', 98: '寝', 99: '谨', 100: '裱',
          101: '褂', 102: '褚', 103: '裸', 104: '裼', 105: '裨', 106: '裾', 107: '裰', 108: '禊', 109: '福', 110: '谩',
          111: '谪', 112: '谫', 113: '谬', 114: '群', 115: '殿', 116: '辟', 117: '障', 118: '媾', 119: '嫫', 120: '媳',
          121: '媲', 122: '嫒', 123: '嫉', 124: '嫌', 125: '嫁', 126: '嫔', 127: '媸', 128: '叠', 129: '缙', 130: '缜',
          131: '缚', 132: '缛', 133: '辔', 134: '缝', 135: '骝', 136: '缟', 137: '缠', 138: '缡', 139: '缢', 140: '缣',
          141: '缤', 142: '骟', 143: '剿', 144: '耥', 145: '璈', 146: '静', 147: '碧', 148: '瑶', 149: '璃', 150: '瑭',
          151: '瑢', 152: '獒', 153: '赘', 154: '熬', 155: '觏', 156: '慝', 157: '嫠', 158: '韬', 159: '髦', 160: '墈',
          161: '墙', 162: '摽', 163: '墟', 164: '撇', 165: '墁', 166: '撂', 167: '摞', 168: '嘉', 169: '摧', 170: '撄',
          171: '赫', 172: '截', 173: '翥', 174: '踅', 175: '誓', 176: '銎', 177: '摭', 178: '墉', 179: '境', 180: '摘',
          181: '墒', 182: '摔', 183: '榖', 184: '撖', 185: '摺', 186: '綦', 187: '聚', 188: '蔫', 189: '蔷', 190: '靺',
          191: '靼', 192: '鞅', 193: '靽', 194: '鞁', 195: '靿', 196: '蔌', 197: '蔽', 198: '慕', 199: '暮', 200: '摹',
          201: '蔓', 202: '蔑', 203: '甍', 204: '蔸', 205: '蓰', 206: '蔹', 207: '蔡', 208: '蔗', 209: '蔟', 210: '蔺',
          211: '戬', 212: '蕖', 213: '蔻', 214: '蓿', 215: '蔼', 216: '斡', 217: '熙', 218: '蔚', 219: '鹕', 220: '兢',
          221: '嘏', 222: '蓼', 223: '榛', 224: '榧', 225: '模', 226: '槚', 227: '槛', 228: '榻', 229: '榫', 230: '槜',
          231: '榭', 232: '槔', 233: '榴', 234: '槁', 235: '榜', 236: '槟', 237: '榨', 238: '榕', 239: '槠', 240: '榷',
          241: '榍', 242: '歌', 243: '遭', 244: '僰', 245: '酵', 246: '酽', 247: '酾', 248: '酲', 249: '酷', 250: '酶',
          251: '酴', 252: '酹', 253: '酿', 254: '酸', 255: '厮'},
    150: {1: '碶', 2: '碡', 3: '碟', 4: '碴', 5: '碱', 6: '碣', 7: '碳', 8: '碲', 9: '磋', 10: '磁', 11: '碹', 12: '碥',
          13: '愿', 14: '劂', 15: '臧', 16: '豨', 17: '殡', 18: '需', 19: '霆', 20: '霁', 21: '辕', 22: '辖', 23: '辗',
          24: '蜚', 25: '裴', 26: '翡', 27: '雌', 28: '龇', 29: '龈', 30: '睿', 31: '弊', 32: '裳', 33: '颗', 34: '夥',
          35: '瞅', 36: '瞍', 37: '睽', 38: '墅', 39: '嘞', 40: '嘈', 41: '嗽', 42: '嘌', 43: '嘁', 44: '嘎', 45: '暧',
          46: '暝', 47: '踌', 48: '踉', 49: '跽', 50: '踊', 51: '蜻', 52: '蜞', 53: '蜡', 54: '蜥', 55: '蜮', 56: '蜾',
          57: '蝈', 58: '蜴', 59: '蝇', 60: '蜘', 61: '蜱', 62: '蜩', 63: '蜷', 64: '蝉', 65: '蜿', 66: '螂', 67: '蜢',
          68: '嘘', 69: '嘡', 70: '鹗', 71: '嘣', 72: '嘤', 73: '嘚', 74: '嘛', 75: '嘀', 76: '嗾', 77: '嘧', 78: '罴',
          79: '罱', 80: '幔', 81: '嶂', 82: '幛', 83: '赙', 84: '罂', 85: '赚', 86: '骷', 87: '骶', 88: '鹘', 89: '锲',
          90: '锴', 91: '锶', 92: '锷', 93: '锸', 94: '锹', 95: '锻', 96: '锽', 97: '锾', 98: '锵', 99: '锿', 100: '镀',
          101: '镁', 102: '镂', 103: '镃', 104: '镄', 105: '镅', 106: '舞', 107: '犒', 108: '舔', 109: '稳', 110: '熏',
          111: '箐', 112: '箦', 113: '箧', 114: '箍', 115: '箸', 116: '箨', 117: '箕', 118: '箬', 119: '算', 120: '箅',
          121: '箩', 122: '箪', 123: '箔', 124: '管', 125: '箜', 126: '箢', 127: '箫', 128: '箓', 129: '毓', 130: '舆',
          131: '僖', 132: '儆', 133: '僳', 134: '僚', 135: '僭', 136: '僬', 137: '劁', 138: '僦', 139: '僮', 140: '僧',
          141: '鼻', 142: '魄', 143: '魅', 144: '魃', 145: '魆', 146: '睾', 147: '艋', 148: '鄱', 149: '貌', 150: '膜',
          151: '膊', 152: '膈', 153: '膀', 154: '膑', 155: '鲑', 156: '鲔', 157: '鲙', 158: '鲚', 159: '鲛', 160: '鲜',
          161: '鲟', 162: '疑', 163: '獐', 164: '獍', 165: '飗', 166: '觫', 167: '雒', 168: '孵', 169: '夤', 170: '馑',
          171: '馒', 172: '銮', 173: '裹', 174: '敲', 175: '豪', 176: '膏', 177: '塾', 178: '遮', 179: '麽', 180: '廙',
          181: '腐', 182: '瘩', 183: '瘌', 184: '瘗', 185: '瘟', 186: '瘦', 187: '瘊', 188: '瘥', 189: '瘘', 190: '瘙',
          191: '廖', 192: '辣', 193: '彰', 194: '竭', 195: '韶', 196: '端', 197: '旗', 198: '旖', 199: '膂', 200: '阚',
          201: '鄯', 202: '鲞', 203: '精', 204: '粼', 205: '粹', 206: '粽', 207: '糁', 208: '歉', 209: '槊', 210: '鹚',
          211: '熄', 212: '熘', 213: '熔', 214: '煽', 215: '熥', 216: '潢', 217: '潆', 218: '潇', 219: '漤', 220: '漆',
          221: '漕', 222: '漱', 223: '漂', 224: '滹', 225: '漫', 226: '漯', 227: '漶', 228: '潋', 229: '潴', 230: '漪',
          231: '漉', 232: '漳', 233: '滴', 234: '漩', 235: '漾', 236: '演', 237: '澉', 238: '漏', 239: '潍', 240: '慢',
          241: '慷', 242: '慵', 243: '寨', 244: '赛', 245: '搴', 246: '寡', 247: '窬', 248: '窨', 249: '窭', 250: '察',
          251: '蜜', 252: '寤', 253: '寥', 254: '谭', 255: '肇'},
    151: {1: '綮', 2: '谮', 3: '褡', 4: '褙', 5: '褐', 6: '褓', 7: '褛', 8: '褊', 9: '褪', 10: '禚', 11: '谯', 12: '谰',
          13: '谱', 14: '谲', 15: '暨', 16: '屣', 17: '鹛', 18: '隧', 19: '嫣', 20: '嫱', 21: '嫩', 22: '嫖', 23: '嫦',
          24: '嫚', 25: '嫘', 26: '嫜', 27: '嫡', 28: '嫪', 29: '鼐', 30: '翟', 31: '翠', 32: '熊', 33: '凳', 34: '瞀',
          35: '鹜', 36: '骠', 37: '缥', 38: '缦', 39: '缧', 40: '骡', 41: '缨', 42: '骢', 43: '缩', 44: '缪', 45: '缫',
          46: '慧', 47: '耦', 48: '耧', 49: '瑾', 50: '璜', 51: '璀', 52: '璎', 53: '璁', 54: '璋', 55: '璇', 56: '璆',
          57: '奭', 58: '撵', 59: '髯', 60: '髫', 61: '撷', 62: '撕', 63: '撒', 64: '撅', 65: '撩', 66: '趣', 67: '趟',
          68: '撑', 69: '撮', 70: '撬', 71: '赭', 72: '播', 73: '墦', 74: '擒', 75: '撸', 76: '鋆', 77: '墩', 78: '撞',
          79: '撤', 80: '撙', 81: '增', 82: '撺', 83: '墀', 84: '撰', 85: '聩', 86: '聪', 87: '觐', 88: '鞋', 89: '鞑',
          90: '蕙', 91: '鞒', 92: '鞍', 93: '蕈', 94: '蕨', 95: '蕤', 96: '蕞', 97: '蕺', 98: '瞢', 99: '蕉', 100: '劐',
          101: '蕃', 102: '蕲', 103: '蕰', 104: '蕊', 105: '赜', 106: '蔬', 107: '蕴', 108: '鼒', 109: '槿', 110: '横',
          111: '樯', 112: '槽', 113: '槭', 114: '樗', 115: '樘', 116: '樱', 117: '樊', 118: '橡', 119: '槲', 120: '樟',
          121: '橄', 122: '敷', 123: '鹝', 124: '豌', 125: '飘', 126: '醋', 127: '醌', 128: '醇', 129: '醉', 130: '醅',
          131: '靥', 132: '魇', 133: '餍', 134: '磕', 135: '磊', 136: '磔', 137: '磙', 138: '磅', 139: '碾', 140: '磉',
          141: '殣', 142: '慭', 143: '震', 144: '霄', 145: '霉', 146: '霈', 147: '辘', 148: '龉', 149: '龊', 150: '觑',
          151: '憋', 152: '瞌', 153: '瞒', 154: '题', 155: '暴', 156: '瞎', 157: '瞑', 158: '嘻', 159: '嘭', 160: '噎',
          161: '嘶', 162: '噶', 163: '嘲', 164: '颙', 165: '暹', 166: '嘹', 167: '影', 168: '踔', 169: '踝', 170: '踢',
          171: '踏', 172: '踟', 173: '踬', 174: '踩', 175: '踮', 176: '踣', 177: '踯', 178: '踪', 179: '踺', 180: '踞',
          181: '蝽', 182: '蝶', 183: '蝾', 184: '蝴', 185: '蝻', 186: '蝠', 187: '蝰', 188: '蝎', 189: '蝌', 190: '蝮',
          191: '螋', 192: '蝗', 193: '蝓', 194: '蝣', 195: '蝼', 196: '蝤', 197: '蝙', 198: '噗', 199: '嘬', 200: '颚',
          201: '嘿', 202: '噍', 203: '噢', 204: '噙', 205: '噜', 206: '噌', 207: '嘱', 208: '噀', 209: '噔', 210: '颛',
          211: '幞', 212: '幡', 213: '嶓', 214: '幢', 215: '嶙', 216: '嶝', 217: '墨', 218: '骺', 219: '骼', 220: '骸',
          221: '镊', 222: '镆', 223: '镇', 224: '镈', 225: '镉', 226: '镋', 227: '镌', 228: '镍', 229: '镎', 230: '镏',
          231: '镐', 232: '镑', 233: '镒', 234: '镓', 235: '镔', 236: '靠', 237: '稽', 238: '稷', 239: '稻', 240: '黎',
          241: '稿', 242: '稼', 243: '箱', 244: '箴', 245: '篑', 246: '篁', 247: '篌', 248: '篓', 249: '箭', 250: '篇',
          251: '篆', 252: '僵', 253: '牖', 254: '儇', 255: '儋'},
    152: {1: '躺', 2: '僻', 3: '德', 4: '徵', 5: '艘', 6: '磐', 7: '虢', 8: '鹞', 9: '鹟', 10: '膝', 11: '膘', 12: '膛',
          13: '滕', 14: '鲠', 15: '鲡', 16: '鲢', 17: '鲣', 18: '鲥', 19: '鲤', 20: '鲦', 21: '鲧', 22: '鲩', 23: '鲪',
          24: '鲫', 25: '鲬', 26: '橥', 27: '獗', 28: '獠', 29: '觯', 30: '鹠', 31: '馓', 32: '馔', 33: '熟', 34: '摩',
          35: '麾', 36: '褒', 37: '廛', 38: '鹡', 39: '瘛', 40: '瘼', 41: '瘪', 42: '瘢', 43: '瘤', 44: '瘠', 45: '瘫',
          46: '齑', 47: '凛', 48: '颜', 49: '毅', 50: '羯', 51: '羰', 52: '糊', 53: '糇', 54: '遴', 55: '糌', 56: '糍',
          57: '糈', 58: '糅', 59: '翦', 60: '遵', 61: '鹣', 62: '熜', 63: '熵', 64: '熠', 65: '潜', 66: '澍', 67: '澎',
          68: '澌', 69: '潵', 70: '潮', 71: '潸', 72: '潭', 73: '潦', 74: '鲨', 75: '潲', 76: '鋈', 77: '潟', 78: '澳',
          79: '潘', 80: '潼', 81: '澈', 82: '澜', 83: '潽', 84: '潺', 85: '澄', 86: '潏', 87: '懂', 88: '憬', 89: '憔',
          90: '懊', 91: '憧', 92: '憎', 93: '寮', 94: '窳', 95: '额', 96: '谳', 97: '翩', 98: '褥', 99: '褴', 100: '褫',
          101: '禤', 102: '谴', 103: '鹤', 104: '谵', 105: '憨', 106: '熨', 107: '慰', 108: '劈', 109: '履', 110: '屦',
          111: '嬉', 112: '勰', 113: '戮', 114: '蝥', 115: '豫', 116: '缬', 117: '缭', 118: '缮', 119: '缯', 120: '骣',
          121: '畿', 122: '耩', 123: '耨', 124: '耪', 125: '璞', 126: '璟', 127: '靛', 128: '璠', 129: '璘', 130: '聱',
          131: '螯', 132: '髻', 133: '髭', 134: '髹', 135: '擀', 136: '撼', 137: '擂', 138: '操', 139: '熹', 140: '甏',
          141: '擐', 142: '擅', 143: '擞', 144: '磬', 145: '鄹', 146: '颞', 147: '蕻', 148: '鞘', 149: '燕', 150: '黇',
          151: '颟', 152: '薤', 153: '蕾', 154: '薯', 155: '薨', 156: '薛', 157: '薇', 158: '檠', 159: '擎', 160: '薪',
          161: '薏', 162: '蕹', 163: '薮', 164: '薄', 165: '颠', 166: '翰', 167: '噩', 168: '薜', 169: '薅', 170: '樾',
          171: '橱', 172: '橛', 173: '橇', 174: '樵', 175: '檎', 176: '橹', 177: '橦', 178: '樽', 179: '樨', 180: '橙',
          181: '橘', 182: '橼', 183: '墼', 184: '整', 185: '橐', 186: '融', 187: '翮', 188: '瓢', 189: '醛', 190: '醐',
          191: '醍', 192: '醒', 193: '醚', 194: '醑', 195: '觱', 196: '磺', 197: '磲', 198: '赝', 199: '飙', 200: '殪',
          201: '霖', 202: '霏', 203: '霓', 204: '霍', 205: '霎', 206: '錾', 207: '辙', 208: '辚', 209: '臻', 210: '冀',
          211: '餐', 212: '遽', 213: '氅', 214: '瞥', 215: '瞟', 216: '瞠', 217: '瞰', 218: '嚄', 219: '嚆', 220: '噤',
          221: '暾', 222: '曈', 223: '蹀', 224: '蹅', 225: '踶', 226: '踹', 227: '踵', 228: '踽', 229: '嘴', 230: '踱',
          231: '蹄', 232: '蹉', 233: '蹁', 234: '蹂', 235: '螨', 236: '蟒', 237: '蟆', 238: '螈', 239: '螅', 240: '螭',
          241: '螗', 242: '螃', 243: '螠', 244: '螟', 245: '噱', 246: '器', 247: '噪', 248: '噬', 249: '噫', 250: '噻',
          251: '噼', 252: '幪', 253: '罹', 254: '圜', 255: '鹦'},
    153: {1: '赠', 2: '默', 3: '黔', 4: '镖', 5: '镗', 6: '镘', 7: '镚', 8: '镛', 9: '镜', 10: '镝', 11: '镞', 12: '镠',
          13: '氇', 14: '氆', 15: '赞', 16: '憩', 17: '穑', 18: '穆', 19: '穄', 20: '篝', 21: '篚', 22: '篥', 23: '篮',
          24: '篡', 25: '簉', 26: '篦', 27: '篪', 28: '篷', 29: '篙', 30: '篱', 31: '盥', 32: '儒', 33: '劓', 34: '翱',
          35: '魉', 36: '魈', 37: '邀', 38: '徼', 39: '衡', 40: '歙', 41: '盦', 42: '膨', 43: '膪', 44: '膳', 45: '螣',
          46: '膦', 47: '膙', 48: '雕', 49: '鲭', 50: '鲮', 51: '鲯', 52: '鲰', 53: '鲱', 54: '鲲', 55: '鲳', 56: '鲴',
          57: '鲵', 58: '鲷', 59: '鲸', 60: '鲺', 61: '鲹', 62: '鲻', 63: '獴', 64: '獭', 65: '獬', 66: '邂', 67: '憝',
          68: '亸', 69: '鹧', 70: '磨', 71: '廨', 72: '赟', 73: '癀', 74: '瘭', 75: '瘰', 76: '廪', 77: '瘿', 78: '瘵',
          79: '瘴', 80: '癃', 81: '瘾', 82: '瘸', 83: '瘳', 84: '斓', 85: '麇', 86: '麈', 87: '凝', 88: '辨', 89: '辩',
          90: '嬴', 91: '壅', 92: '羲', 93: '糙', 94: '糗', 95: '糖', 96: '糕', 97: '甑', 98: '燎', 99: '燠', 100: '燔',
          101: '燃', 102: '燧', 103: '燊', 104: '燏', 105: '濑', 106: '濒', 107: '濉', 108: '潞', 109: '澧', 110: '澡',
          111: '澴', 112: '激', 113: '澹', 114: '澥', 115: '澶', 116: '濂', 117: '澼', 118: '憷', 119: '懒', 120: '憾',
          121: '懈', 122: '黉', 123: '褰', 124: '寰', 125: '窸', 126: '窿', 127: '褶', 128: '禧', 129: '壁', 130: '避',
          131: '嬖', 132: '犟', 133: '隰', 134: '嬗', 135: '鹨', 136: '翯', 137: '颡', 138: '缰', 139: '缱', 140: '缲',
          141: '缳', 142: '缴', 143: '璨', 144: '璩', 145: '璐', 146: '璪', 147: '戴', 148: '螫', 149: '擤', 150: '壕',
          151: '擦', 152: '觳', 153: '罄', 154: '擢', 155: '藉', 156: '薹', 157: '鞡', 158: '鞠', 159: '藏', 160: '薷',
          161: '薰', 162: '藐', 163: '藓', 164: '藁', 165: '檬', 166: '檑', 167: '檄', 168: '檐', 169: '檩', 170: '檀',
          171: '懋', 172: '醢', 173: '翳', 174: '繄', 175: '礁', 176: '礅', 177: '磷', 178: '磴', 179: '鹩', 180: '霜',
          181: '霞', 182: '龋', 183: '龌', 184: '豳', 185: '壑', 186: '黻', 187: '瞭', 188: '瞧', 189: '瞬', 190: '瞳',
          191: '瞵', 192: '瞩', 193: '瞪', 194: '嚏', 195: '曙', 196: '嚅', 197: '蹑', 198: '蹒', 199: '蹋', 200: '蹈',
          201: '蹊', 202: '蹓', 203: '蹐', 204: '蟥', 205: '螬', 206: '螵', 207: '疃', 208: '螳', 209: '螺', 210: '蟋',
          211: '蟑', 212: '蟀', 213: '嚎', 214: '嚓', 215: '羁', 216: '罽', 217: '罾', 218: '嶷', 219: '赡', 220: '黜',
          221: '黝', 222: '髁', 223: '髀', 224: '镡', 225: '镢', 226: '镣', 227: '镤', 228: '镥', 229: '镦', 230: '镧',
          231: '镨', 232: '镩', 233: '镪', 234: '镫', 235: '罅', 236: '穗', 237: '黏', 238: '魏', 239: '簧', 240: '簌',
          241: '篾', 242: '簃', 243: '篼', 244: '簏', 245: '簇', 246: '簖', 247: '簋', 248: '繁', 249: '鼢', 250: '黛',
          251: '儡', 252: '鹪', 253: '鼾', 254: '皤', 255: '魍'},
    154: {1: '徽', 2: '艚', 3: '龠', 4: '爵', 5: '繇', 6: '貘', 7: '邈', 8: '貔', 9: '臌', 10: '朦', 11: '臊', 12: '膻',
          13: '臁', 14: '臆', 15: '臃', 16: '鲼', 17: '鲽', 18: '鲾', 19: '鳀', 20: '鳁', 21: '鳂', 22: '鳃', 23: '鳄',
          24: '鳅', 25: '鳆', 26: '鳇', 27: '鳈', 28: '鳉', 29: '鳊', 30: '獯', 31: '螽', 32: '燮', 33: '鹫', 34: '襄',
          35: '糜', 36: '縻', 37: '膺', 38: '癍', 39: '癌', 40: '麋', 41: '辫', 42: '赢', 43: '糟', 44: '糠', 45: '馘',
          46: '燥', 47: '懑', 48: '濡', 49: '濮', 50: '濞', 51: '濠', 52: '濯', 53: '懦', 54: '豁', 55: '蹇', 56: '謇',
          57: '邃', 58: '襕', 59: '襁', 60: '臀', 61: '檗', 62: '甓', 63: '臂', 64: '擘', 65: '孺', 66: '隳', 67: '嬷',
          68: '翼', 69: '蟊', 70: '鹬', 71: '鍪', 72: '骤', 73: '鏊', 74: '鳌', 75: '鬹', 76: '鬈', 77: '鬃', 78: '瞽',
          79: '藕', 80: '鞯', 81: '鞨', 82: '鞭', 83: '鞫', 84: '鞧', 85: '鞣', 86: '藜', 87: '藠', 88: '藤', 89: '藩',
          90: '鹲', 91: '檫', 92: '檵', 93: '覆', 94: '醪', 95: '蹙', 96: '礞', 97: '礓', 98: '礌', 99: '燹', 100: '餮',
          101: '蹩', 102: '瞿', 103: '瞻', 104: '曛', 105: '颢', 106: '曜', 107: '躇', 108: '蹦', 109: '鹭', 110: '蹢',
          111: '蹜', 112: '蟛', 113: '蟪', 114: '蟠', 115: '蟮', 116: '嚚', 117: '嚣', 118: '鹮', 119: '黠', 120: '黟',
          121: '髅', 122: '髂', 123: '镬', 124: '镭', 125: '镯', 126: '镰', 127: '镱', 128: '馥', 129: '簠', 130: '簟',
          131: '簪', 132: '簦', 133: '鼫', 134: '鼬', 135: '鼩', 136: '雠', 137: '艟', 138: '翻', 139: '臑', 140: '鳍',
          141: '鳎', 142: '鳏', 143: '鳐', 144: '鳑', 145: '鹱', 146: '鹰', 147: '癞', 148: '癔', 149: '癜', 150: '癖',
          151: '糨', 152: '冁', 153: '瀑', 154: '瀍', 155: '瀌', 156: '鎏', 157: '懵', 158: '襟', 159: '璧', 160: '戳',
          161: '彝', 162: '邋', 163: '鬏', 164: '攉', 165: '攒', 166: '鞲', 167: '鞴', 168: '藿', 169: '蘧', 170: '孽',
          171: '蘅', 172: '警', 173: '蘑', 174: '藻', 175: '麓', 176: '攀', 177: '醭', 178: '醮', 179: '醯', 180: '礤',
          181: '酃', 182: '霪', 183: '霭', 184: '黼', 185: '鳖', 186: '曝', 187: '嚯', 188: '蹰', 189: '蹶', 190: '蹽',
          191: '蹼', 192: '蹯', 193: '蹴', 194: '蹾', 195: '蹲', 196: '蹭', 197: '蹿', 198: '蹬', 199: '蠖', 200: '蠓',
          201: '蠋', 202: '蟾', 203: '蠊', 204: '巅', 205: '黢', 206: '髋', 207: '髌', 208: '镲', 209: '籀', 210: '簸',
          211: '籁', 212: '簿', 213: '鳘', 214: '齁', 215: '魑', 216: '艨', 217: '鼗', 218: '鳓', 219: '鳔', 220: '鳕',
          221: '鳗', 222: '鳙', 223: '鳚', 224: '蟹', 225: '颤', 226: '靡', 227: '癣', 228: '麒', 229: '鏖', 230: '瓣',
          231: '蠃', 232: '羸', 233: '羹', 234: '爆', 235: '瀚', 236: '瀣', 237: '瀛', 238: '襦', 239: '谶', 240: '襞',
          241: '疆', 242: '骥', 243: '缵', 244: '瓒', 245: '鬓', 246: '壤', 247: '攘', 248: '馨', 249: '蘩', 250: '蘖',
          251: '蘘', 252: '醵', 253: '醴', 254: '霰', 255: '颥'},
    155: {1: '酆', 2: '耀', 3: '矍', 4: '曦', 5: '躁', 6: '躅', 7: '蠕', 8: '鼍', 9: '嚼', 10: '嚷', 11: '巍', 12: '巉',
          13: '黩', 14: '黥', 15: '镳', 16: '镴', 17: '黧', 18: '籍', 19: '纂', 20: '鼯', 21: '犨', 22: '臜', 23: '鳜',
          24: '鳝', 25: '鳞', 26: '鳟', 27: '獾', 28: '魔', 29: '糯', 30: '灌', 31: '瀹', 32: '瀵', 33: '譬', 34: '孀',
          35: '骧', 36: '耰', 37: '蠢', 38: '瓘', 39: '鼙', 40: '醺', 41: '礴', 42: '礳', 43: '霸', 44: '露', 45: '霹',
          46: '颦', 47: '曩', 48: '躏', 49: '黯', 50: '髓', 51: '鼱', 52: '鳡', 53: '鳢', 54: '癫', 55: '麝', 56: '赣',
          57: '夔', 58: '爝', 59: '灏', 60: '禳', 61: '鐾', 62: '羼', 63: '蠡', 64: '耲', 65: '耱', 66: '懿', 67: '韂',
          68: '蘸', 69: '鹳', 70: '糵', 71: '蘼', 72: '囊', 73: '霾', 74: '氍', 75: '饕', 76: '躔', 77: '躐', 78: '髑',
          79: '镵', 80: '镶', 81: '穰', 82: '鳤', 83: '瓤', 84: '饔', 85: '鬻', 86: '鬟', 87: '趱', 88: '攫', 89: '攥',
          90: '颧', 91: '躜', 92: '罐', 93: '鼹', 94: '鼷', 95: '癯', 96: '麟', 97: '蠲', 98: '矗', 99: '蠹', 100: '醾',
          101: '躞', 102: '衢', 103: '鑫', 104: '灞', 105: '襻', 106: '纛', 107: '鬣', 108: '攮', 109: '囔', 110: '馕',
          111: '戆', 112: '蠼', 113: '爨', 114: '齉'}
}
REVERSE_FONT_MAPPING = {}
for first_byte, inner_dict in FONT_MAPPING.items():
    for second_byte, character in inner_dict.items():
        REVERSE_FONT_MAPPING[character] = (first_byte, second_byte)
CHINESE_CHARSET = "".join(REVERSE_FONT_MAPPING.keys())
VALID_CHARACTERS = chirp_common.CHARSET_ASCII + CHINESE_CHARSET


def convert_bytes_to_chinese(data: bytes) -> str:
    """Convert bytes to a string of chinese characters"""
    last_byte = 0x00
    text = ''
    for byte in data:
        if last_byte == 0x00 and byte == 0xFF or byte == 0x00:
            break
        if byte >= 0x80 and last_byte == 0x00:
            last_byte = byte
            continue
        if last_byte != 0x00:
            text += FONT_MAPPING[last_byte][byte]
            last_byte = 0x00
            continue
        text += chr(byte)
    return text


def convert_chinese_to_ascii_chars(data: str) -> str:
    text = ''
    for char in data:
        if char in chirp_common.CHARSET_ASCII:
            text += char
        elif char in CHINESE_CHARSET:
            reverse_str = REVERSE_FONT_MAPPING[char]
            text += chr(reverse_str[0])
            text += chr(reverse_str[1])
    return text


class RadioSettingChineseValueString(RadioSettingValueString):

    """A string setting"""

    def __init__(self, minlength, maxlength, current,
                 autopad=True, charset=chirp_common.CHARSET_ASCII):
        RadioSettingValueString.__init__(self, minlength, maxlength, current, autopad, charset)

    def set_value(self, value):
        if len(value) < self._minlength or len(convert_chinese_to_ascii_chars(value)) > self._maxlength:
            raise InvalidValueError("Value must be between %i and %i chars" %
                                    (self._minlength, self._maxlength))
        if self._autopad:
            value = value.ljust(self._maxlength)
        for char in value:
            if char not in self._charset:
                raise InvalidValueError("Value contains invalid " +
                                        "character `%s'" % char)
        RadioSettingValue.set_value(self, value)


# the communication is obfuscated using this fine mechanism
def xorarr(data: bytes):
    tbl = [22, 108, 20, 230, 46, 145, 13, 64, 33, 53, 213, 64, 19, 3, 233, 128]
    x = b""
    r = 0
    for byte in data:
        x += bytes([byte ^ tbl[r]])
        r = (r+1) % len(tbl)
    return x


# if this crc was used for communication to AND from the radio, then it
# would be a measure to increase reliability.
# but it's only used towards the radio, so it's for further obfuscation
def calculate_crc16_xmodem(data: bytes):
    poly = 0x1021
    crc = 0x0
    for byte in data:
        crc = crc ^ (byte << 8)
        for i in range(8):
            crc = crc << 1
            if (crc & 0x10000):
                crc = (crc ^ poly) & 0xFFFF
    return crc & 0xFFFF


def _send_command(serport, data: bytes):
    """Send a command to UV-K5 radio"""
    LOG.debug("Sending command (unobfuscated) len=0x%4.4x:\n%s" %
              (len(data), util.hexprint(data)))

    crc = calculate_crc16_xmodem(data)
    data2 = data + struct.pack("<H", crc)

    command = struct.pack(">HBB", 0xabcd, len(data), 0) + \
        xorarr(data2) + \
        struct.pack(">H", 0xdcba)
    if DEBUG_SHOW_OBFUSCATED_COMMANDS:
        LOG.debug("Sending command (obfuscated):\n%s" % util.hexprint(command))
    try:
        result = serport.write(command)
    except Exception:
        raise errors.RadioError("Error writing data to radio")
    return result


def _receive_reply(serport):
    header = serport.read(4)
    if len(header) != 4:
        LOG.warning("Header short read: [%s] len=%i" %
                    (util.hexprint(header), len(header)))
        raise errors.RadioError("Header short read")
    if header[0] != 0xAB or header[1] != 0xCD or header[3] != 0x00:
        LOG.warning("Bad response header: %s len=%i" %
                    (util.hexprint(header), len(header)))
        raise errors.RadioError("Bad response header")

    cmd = serport.read(int(header[2]))
    if len(cmd) != int(header[2]):
        LOG.warning("Body short read: [%s] len=%i" %
                    (util.hexprint(cmd), len(cmd)))
        raise errors.RadioError("Command body short read")

    footer = serport.read(4)

    if len(footer) != 4:
        LOG.warning("Footer short read: [%s] len=%i" %
                    (util.hexprint(footer), len(footer)))
        raise errors.RadioError("Footer short read")

    if footer[2] != 0xDC or footer[3] != 0xBA:
        LOG.debug(
                "Reply before bad response footer (obfuscated)"
                "len=0x%4.4x:\n%s" % (len(cmd), util.hexprint(cmd)))
        LOG.warning("Bad response footer: %s len=%i" %
                    (util.hexprint(footer), len(footer)))
        raise errors.RadioError("Bad response footer")

    if DEBUG_SHOW_OBFUSCATED_COMMANDS:
        LOG.debug("Received reply (obfuscated) len=0x%4.4x:\n%s" %
                  (len(cmd), util.hexprint(cmd)))

    cmd2 = xorarr(cmd)

    LOG.debug("Received reply (unobfuscated) len=0x%4.4x:\n%s" %
              (len(cmd2), util.hexprint(cmd2)))

    return cmd2


def _getstring(data: bytes, begin, maxlen):
    tmplen = min(maxlen+1, len(data))
    s = [data[i] for i in range(begin, tmplen)]
    for key, val in enumerate(s):
        if val < ord(' ') or val > ord('~'):
            break
    return ''.join(chr(x) for x in s[0:key])


def _sayhello(serport):
    hellopacket = b"\x14\x05\x04\x00\x6a\x39\x57\x64"

    tries = 5
    while True:
        LOG.debug("Sending hello packet")
        _send_command(serport, hellopacket)
        o = _receive_reply(serport)
        if (o):
            break
        tries -= 1
        if tries == 0:
            LOG.warning("Failed to initialise radio")
            raise errors.RadioError("Failed to initialize radio")
    firmware = _getstring(o, 4, 16)
    LOG.info("Found firmware: %s" % firmware)
    return firmware


def _readmem(serport, offset, length):
    LOG.debug("Sending readmem offset=0x%4.4x len=0x%4.4x" % (offset, length))

    readmem = b"\x1b\x05\x08\x00" + \
        struct.pack("<HBB", offset, length, 0) + \
        b"\x6a\x39\x57\x64"
    _send_command(serport, readmem)
    o = _receive_reply(serport)
    if DEBUG_SHOW_MEMORY_ACTIONS:
        LOG.debug("readmem Received data len=0x%4.4x:\n%s" %
                  (len(o), util.hexprint(o)))
    return o[8:]


def _read_add_mem(serport, offset, length, add: list):
    LOG.debug(
        "Sending read_add_mem offset=0x%4.4x len=0x%4.4x add=[0x%4.4x, 0x%4.4x]" % (offset, length, add[0], add[1]))

    readmem = b"\x2b\x05\x08\x00" + \
              struct.pack("<HBB", offset, length, 0) + \
              b"\x6a\x39\x57\x64" + \
              struct.pack("<BB", add[0], add[1])
    _send_command(serport, readmem)
    o = _receive_reply(serport)
    if DEBUG_SHOW_MEMORY_ACTIONS:
        LOG.debug("read_add_mem Received data len=0x%4.4x:\n%s" %
                  (len(o), util.hexprint(o)))
    return o[8:]


def _write_add_mem(serport, offset, add, data):
    length = len(data) + len(add)
    LOG.debug("Sending write_add_mem offset=0x%4.4x len=0x%4.4x add=[0x%4.4x, 0x%4.4x]" %
              (offset, length, add[0], add[1]))

    if DEBUG_SHOW_MEMORY_ACTIONS:
        LOG.debug("write_add_mem sent data offset=0x%4.4x len=0x%4.4x add=[0x%4.4x, 0x%4.4x]:\n%s" %
                  (offset, length, add[0], add[1], util.hexprint(data)))

    writemem = b"\x38\x05\x1c\x00" + \
        struct.pack("<HBB", offset, length, 0) + \
        b"\x6a\x39\x57\x64" + \
        struct.pack("<BB", add[0], add[1]) + data

    _send_command(serport, writemem)
    o = _receive_reply(serport)

    LOG.debug("write_add_mem Received data: %s len=%i" % (util.hexprint(o), len(o)))

    if (o[0] == 0x1e
            and
            o[4] == (offset & 0xff)
            and
            o[5] == (offset >> 8) & 0xff):
        return True
    else:
        LOG.warning("Bad data from write_add_mem")
        raise errors.RadioError("Bad response to write_add_mem")


def _writemem(serport, data, offset):
    LOG.debug("Sending writemem offset=0x%4.4x len=0x%4.4x" %
              (offset, len(data)))

    if DEBUG_SHOW_MEMORY_ACTIONS:
        LOG.debug("writemem sent data offset=0x%4.4x len=0x%4.4x:\n%s" %
                  (offset, len(data), util.hexprint(data)))

    dlen = len(data)
    writemem = b"\x1d\x05" + \
        struct.pack("<BBHBB", dlen+8, 0, offset, dlen, 1) + \
        b"\x6a\x39\x57\x64"+data

    _send_command(serport, writemem)
    o = _receive_reply(serport)

    LOG.debug("writemem Received data: %s len=%i" % (util.hexprint(o), len(o)))

    if (o[0] == 0x1e
            and
            o[4] == (offset & 0xff)
            and
            o[5] == (offset >> 8) & 0xff):
        return True
    else:
        LOG.warning("Bad data from writemem")
        raise errors.RadioError("Bad response to writemem")


def _resetradio(serport):
    resetpacket = b"\xdd\x05\x00\x00"
    _send_command(serport, resetpacket)


def do_download(radio):
    serport = radio.pipe
    serport.timeout = 0.5
    status = chirp_common.Status()
    status.cur = 0
    status.max = MEM_SIZE
    status.msg = "Downloading from radio"
    radio.status_fn(status)

    eeprom = b""
    f = _sayhello(serport)
    if f:
        radio.FIRMWARE_VERSION = f
    else:
        raise errors.RadioError('Unable to determine firmware version')

    addr = 0
    while addr < MEM_SIZE:
        o = _readmem(serport, addr, MEM_BLOCK)
        status.cur = addr
        radio.status_fn(status)

        if o and len(o) == MEM_BLOCK:
            eeprom += o
            addr += MEM_BLOCK
        else:
            raise errors.RadioError("Memory download incomplete")

    return memmap.MemoryMapBytes(eeprom)


def do_add_download(radio):
    serport = radio.pipe
    serport.timeout = 0.5
    status = chirp_common.Status()
    status.cur = 0
    status.max = 3
    status.msg = "Downloading added data from radio"
    radio.status_fn(status)

    f = _sayhello(serport)
    if f:
        radio.FIRMWARE_VERSION = f
    else:
        raise errors.RadioError('Unable to determine firmware version')

    welcome_len = _read_add_mem(serport, 0x01, 0x02, [0x1E, 0xE3])
    status.cur = 1
    radio.status_fn(status)
    welcome_len1, welcome_len2 = welcome_len
    if welcome_len1 > 18:
        welcome_len1 = 18
    if welcome_len2 > 18:
        welcome_len2 = 18
    welcome_text_1 = _read_add_mem(serport, 0x01, welcome_len1, [0x20, 0xE3])
    status.cur = 2
    radio.status_fn(status)
    welcome_text_2 = _read_add_mem(serport, 0x01, welcome_len2, [0x33, 0xE3])
    status.cur = 3
    radio.status_fn(status)
    return [welcome_text_1, welcome_text_2]


def do_upload(radio):
    serport = radio.pipe
    serport.timeout = 0.5
    status = chirp_common.Status()
    status.cur = 0
    status.max = PROG_SIZE
    status.msg = "Uploading to radio"
    radio.status_fn(status)

    f = _sayhello(serport)
    if f:
        radio.FIRMWARE_VERSION = f
    else:
        return False

    addr = 0
    while addr < PROG_SIZE:
        o = radio.get_mmap()[addr:addr+MEM_BLOCK]
        _writemem(serport, o, addr)
        status.cur = addr
        radio.status_fn(status)
        if o:
            addr += MEM_BLOCK
        else:
            raise errors.RadioError("Memory upload incomplete")
    status.msg = "Uploaded OK"

    return True


def do_add_upload(radio):
    serport = radio.pipe
    serport.timeout = 0.5
    status = chirp_common.Status()
    status.cur = 0
    status.max = 15
    status.msg = "Uploading add data to radio"
    radio.status_fn(status)

    f = _sayhello(serport)
    if f:
        radio.FIRMWARE_VERSION = f
    else:
        return False

    welcome_logo = radio.get_welcome_logo()
    _write_add_mem(serport, 0x01, [0x1E, 0xE3], bytes([len(x) for x in welcome_logo]))
    status.cur += 1
    radio.status_fn(status)
    _write_add_mem(serport, 0x01, [0x20, 0xE3], b'\x00' * 18)
    _write_add_mem(serport, 0x01, [0x20, 0xE3], welcome_logo[0])
    status.cur += 1
    radio.status_fn(status)
    _write_add_mem(serport, 0x01, [0x33, 0xE3], b'\x00' * 18)
    _write_add_mem(serport, 0x01, [0x33, 0xE3], welcome_logo[1])
    status.cur += 1
    radio.status_fn(status)

    addr = 0x1D00
    _memobj = radio.get_memobj()
    _write_add_mem(serport, 0x0, struct.pack("<H", 0x1fff), _memobj.mdc_num.get_raw())
    status.cur += 1
    radio.status_fn(status)
    for i in range(1, 23):
        mdc_id = _memobj.mdccontact1[i - 1].id
        mdc_name = _memobj.mdccontact1[i - 1].name
        data = mdc_id.get_raw() + mdc_name.get_raw()
        _write_add_mem(serport, 0x0, struct.pack("<H", addr), data)
        addr += 0x10
        status.cur += 1
        radio.status_fn(status)
        if i==16:
              addr=0x1f90
    status.msg = "Uploaded OK"

    return True


def _find_band(nolimits, hz):
    mhz = hz/1000000.0
    if nolimits:
        B = BANDS_NOLIMITS
    else:
        B = BANDS

    # currently the hacked firmware sets band=1 below 50 MHz
    if nolimits and mhz < 50.0:
        return 1

    for a in B:
        if mhz >= B[a][0] and mhz <= B[a][1]:
            return a
    return False


@directory.register
class UVK5Radio(chirp_common.CloneModeRadio):
    """Quansheng UV-K5"""
    VENDOR = "Quansheng"
    MODEL = "UV-K5 (cn)"
    BAUD_RATE = 38400
    NEEDS_COMPAT_SERIAL = False
    FIRMWARE_VERSION = ""
    _expanded_limits = False

    def __init__(self, pipe):
          super().__init__(pipe)
          self._welcome_logo = [b'', b'']

    def get_prompts(x=None):
        rp = chirp_common.RadioPrompts()
        rp.experimental = _(
            'This is an experimental driver for the Quansheng UV-K5. '
            'It may harm your radio, or worse. Use at your own risk.\n\n'
            'Before attempting to do any changes please download '
            'the memory image from the radio with chirp '
            'and keep it. This can be later used to recover the '
            'original settings. \n\n'
            'some details are not yet implemented')
        rp.pre_download = _(
            "1. Turn radio on.\n"
            "2. Connect cable to mic/spkr connector.\n"
            "3. Make sure connector is firmly connected.\n"
            "4. Click OK to download image from device.\n\n"
            "It will may not work if you turn on the radio "
            "with the cable already attached\n")
        rp.pre_upload = _(
            "1. Turn radio on.\n"
            "2. Connect cable to mic/spkr connector.\n"
            "3. Make sure connector is firmly connected.\n"
            "4. Click OK to upload the image to device.\n\n"
            "It will may not work if you turn on the radio "
            "with the cable already attached")
        return rp

    # Return information about this radio's features, including
    # how many memories it has, what bands it supports, etc
    def get_features(self):
        rf = chirp_common.RadioFeatures()
        rf.has_bank = False
        rf.valid_dtcs_codes = DTCS_CODES
        rf.has_rx_dtcs = True
        rf.has_ctone = True
        rf.has_settings = True
        rf.has_comment = False
        rf.valid_name_length = 10
        rf.valid_power_levels = UVK5_POWER_LEVELS
        rf.valid_special_chans = list(SPECIALS.keys())
        rf.valid_duplexes = ["", "-", "+", "off"]

        # hack so we can input any frequency,
        # the 0.1 and 0.01 steps don't work unfortunately
        rf.valid_tuning_steps = [0.01, 0.1, 1.0] + STEPS

        rf.valid_tmodes = ["", "Tone", "TSQL", "DTCS", "Cross"]
        rf.valid_cross_modes = ["Tone->Tone", "Tone->DTCS", "DTCS->Tone",
                                "->Tone", "->DTCS", "DTCS->", "DTCS->DTCS"]

        rf.valid_characters = VALID_CHARACTERS
        rf.valid_modes = ["FM", "NFM", "AM", "NAM"]
        rf.valid_tmodes = ["", "Tone", "TSQL", "DTCS", "Cross"]

        rf.valid_skips = [""]

        # This radio supports memories 1-200, 201-214 are the VFO memories
        rf.memory_bounds = (1, 200)

        rf.valid_bands = []
        for a in BANDS_NOLIMITS:
            rf.valid_bands.append(
                    (int(BANDS_NOLIMITS[a][0]*1000000),
                     int(BANDS_NOLIMITS[a][1]*1000000)))
        return rf

    # Do a download of the radio from the serial port
    def sync_in(self):
        self._mmap = do_download(self)
        self._welcome_logo = do_add_download(self)
        self.process_mmap()

    # Do an upload of the radio to the serial port
    def sync_out(self):
        do_upload(self)
        do_add_upload(self)
        _resetradio(self.pipe)

    # Convert the raw byte array into a memory object structure
    def process_mmap(self):
        self._memobj = bitwise.parse(MEM_FORMAT, self._mmap)

    # Return a raw representation of the memory object, which
    # is very helpful for development
    def get_raw_memory(self, number):
        return repr(self._memobj.channel[number-1])

    def get_welcome_logo(self):
        return self._welcome_logo

    def validate_memory(self, mem):
        msgs = super().validate_memory(mem)

        if mem.duplex == 'off':
            return msgs

        # find tx frequency
        if mem.duplex == '-':
            txfreq = mem.freq - mem.offset
        elif mem.duplex == '+':
            txfreq = mem.freq + mem.offset
        else:
            txfreq = mem.freq

        # find band
        band = _find_band(self._expanded_limits, txfreq)
        if band is False:
            msg = "Transmit frequency %.4f MHz is not supported by this radio"\
                   % (txfreq/1000000.0)
            msgs.append(chirp_common.ValidationError(msg))

        band = _find_band(self._expanded_limits, mem.freq)
        if band is False:
            msg = "The frequency %.4f MHz is not supported by this radio" \
                   % (mem.freq/1000000.0)
            msgs.append(chirp_common.ValidationError(msg))

        return msgs

    def _set_tone(self, mem, _mem):
        ((txmode, txtone, txpol),
         (rxmode, rxtone, rxpol)) = chirp_common.split_tone_encode(mem)

        if txmode == "Tone":
            txtoval = CTCSS_TONES.index(txtone)
            txmoval = 0b01
        elif txmode == "DTCS":
            txmoval = txpol == "R" and 0b11 or 0b10
            txtoval = DTCS_CODES.index(txtone)
        else:
            txmoval = 0
            txtoval = 0

        if rxmode == "Tone":
            rxtoval = CTCSS_TONES.index(rxtone)
            rxmoval = 0b01
        elif rxmode == "DTCS":
            rxmoval = rxpol == "R" and 0b11 or 0b10
            rxtoval = DTCS_CODES.index(rxtone)
        else:
            rxmoval = 0
            rxtoval = 0

        _mem.rxcodeflag = rxmoval
        _mem.txcodeflag = txmoval
        _mem.unknown1 = 0
        _mem.unknown2 = 0
        _mem.rxcode = rxtoval
        _mem.txcode = txtoval

    def _get_tone(self, mem, _mem):
        rxtype = _mem.rxcodeflag
        txtype = _mem.txcodeflag
        rx_tmode = TMODES[rxtype]
        tx_tmode = TMODES[txtype]

        rx_tone = tx_tone = None

        if tx_tmode == "Tone":
            if _mem.txcode < len(CTCSS_TONES):
                tx_tone = CTCSS_TONES[_mem.txcode]
            else:
                tx_tone = 0
                tx_tmode = ""
        elif tx_tmode == "DTCS":
            if _mem.txcode < len(DTCS_CODES):
                tx_tone = DTCS_CODES[_mem.txcode]
            else:
                tx_tone = 0
                tx_tmode = ""

        if rx_tmode == "Tone":
            if _mem.rxcode < len(CTCSS_TONES):
                rx_tone = CTCSS_TONES[_mem.rxcode]
            else:
                rx_tone = 0
                rx_tmode = ""
        elif rx_tmode == "DTCS":
            if _mem.rxcode < len(DTCS_CODES):
                rx_tone = DTCS_CODES[_mem.rxcode]
            else:
                rx_tone = 0
                rx_tmode = ""

        tx_pol = txtype == 0x03 and "R" or "N"
        rx_pol = rxtype == 0x03 and "R" or "N"

        chirp_common.split_tone_decode(mem, (tx_tmode, tx_tone, tx_pol),
                                       (rx_tmode, rx_tone, rx_pol))

    # Extract a high-level memory object from the low-level memory map
    # This is called to populate a memory in the UI
    def get_memory(self, number2):

        mem = chirp_common.Memory()

        if isinstance(number2, str):
            number = SPECIALS[number2]
            mem.extd_number = number2
        else:
            number = number2 - 1

        mem.number = number + 1

        _mem = self._memobj.channel[number]

        tmpcomment = ""

        is_empty = False
        # We'll consider any blank (i.e. 0 MHz frequency) to be empty
        if (_mem.freq == 0xffffffff) or (_mem.freq == 0):
            is_empty = True

        tmpscn = SCANLIST_LIST[0]

        # We'll also look at the channel attributes if a memory has them
        if number < 200:
            _mem3 = self._memobj.channel_attributes[number]
            # free memory bit
            if _mem3.is_free > 0:
                is_empty = True
            # scanlists
            if _mem3.is_scanlist1 > 0 and _mem3.is_scanlist2 > 0:
                tmpscn = SCANLIST_LIST[3]  # "1+2"
            elif _mem3.is_scanlist1 > 0:
                tmpscn = SCANLIST_LIST[1]  # "1"
            elif _mem3.is_scanlist2 > 0:
                tmpscn = SCANLIST_LIST[2]  # "2"

        if is_empty:
            mem.empty = True
            # set some sane defaults:
            mem.power = UVK5_POWER_LEVELS[2]
            mem.extra = RadioSettingGroup("Extra", "extra")
            rs = RadioSetting(
                "bclo", "BCLO",
                RadioSettingValueBoolean(False))
            mem.extra.append(rs)
            rs = RadioSetting(
                "frev", "FreqRev",
                RadioSettingValueBoolean(False))
            mem.extra.append(rs)
            rs = RadioSetting(
                "pttid", "PTTID",
                RadioSettingValueList(PTTID_LIST, PTTID_LIST[0]))
            mem.extra.append(rs)
            rs = RadioSetting(
                "dtmfdecode", _("DTMF decode"),
                RadioSettingValueBoolean(False))
            mem.extra.append(rs)
            rs = RadioSetting(
                "scrambler", _("Scrambler"),
                RadioSettingValueList(SCRAMBLER_LIST, SCRAMBLER_LIST[0]))
            mem.extra.append(rs)

            rs = RadioSetting(
                "scanlists", _("Scanlists"),
                RadioSettingValueList(SCANLIST_LIST, SCANLIST_LIST[0]))
            mem.extra.append(rs)

            # actually the step and duplex are overwritten by chirp based on
            # bandplan. they are here to document sane defaults for IARU r1
            # mem.tuning_step = 25.0
            # mem.duplex = ""

            return mem

        if number > 199:
            mem.immutable = ["name", "scanlists"]
        else:
            _mem2 = self._memobj.channelname[number]
            raw_bytes = _mem2.get_raw()
            mem.name = convert_bytes_to_chinese(raw_bytes).rstrip()

        # Convert your low-level frequency to Hertz
        mem.freq = int(_mem.freq)*10
        mem.offset = int(_mem.offset)*10

        if (mem.offset == 0):
            mem.duplex = ''
        else:
            if _mem.shift == FLAGS1_OFFSET_MINUS:
                if _mem.freq == _mem.offset:
                    # fake tx disable by setting tx to 0 MHz
                    mem.duplex = 'off'
                    mem.offset = 0
                else:
                    mem.duplex = '-'
            elif _mem.shift == FLAGS1_OFFSET_PLUS:
                mem.duplex = '+'
            else:
                mem.duplex = ''

        # tone data
        self._get_tone(mem, _mem)

        # mode
        if _mem.enable_am > 0:
            if _mem.bandwidth > 0:
                mem.mode = "NAM"
            else:
                mem.mode = "AM"
        else:
            if _mem.bandwidth > 0:
                mem.mode = "NFM"
            else:
                mem.mode = "FM"

        # tuning step
        tstep = _mem.step & 0x7
        if tstep < len(STEPS):
            mem.tuning_step = STEPS[tstep]
        else:
            mem.tuning_step = 2.5

        # power
        if _mem.txpower == POWER_HIGH:
            mem.power = UVK5_POWER_LEVELS[2]
        elif _mem.txpower == POWER_MEDIUM:
            mem.power = UVK5_POWER_LEVELS[1]
        else:
            mem.power = UVK5_POWER_LEVELS[0]

        # We'll consider any blank (i.e. 0 MHz frequency) to be empty
        if (_mem.freq == 0xffffffff) or (_mem.freq == 0):
            mem.empty = True
        else:
            mem.empty = False

        mem.extra = RadioSettingGroup("Extra", "extra")

        # BCLO
        is_bclo = bool(_mem.bclo > 0)
        rs = RadioSetting("bclo", "BCLO", RadioSettingValueBoolean(is_bclo))
        mem.extra.append(rs)
        tmpcomment += "BCLO:"+(is_bclo and "ON" or "off")+" "

        # Frequency reverse - whatever that means, don't see it in the manual
        is_frev = bool(_mem.freq_reverse > 0)
        rs = RadioSetting("frev", "FreqRev", RadioSettingValueBoolean(is_frev))
        mem.extra.append(rs)
        tmpcomment += "FreqReverse:"+(is_frev and "ON" or "off")+" "

        # PTTID
        pttid = _mem.dtmf_pttid
        rs = RadioSetting("pttid", "PTTID", RadioSettingValueList(
            PTTID_LIST, PTTID_LIST[pttid]))
        mem.extra.append(rs)
        tmpcomment += "PTTid:"+PTTID_LIST[pttid]+" "

        # DTMF DECODE
        is_dtmf = bool(_mem.dtmf_decode > 0)
        rs = RadioSetting("dtmfdecode", _("DTMF decode"),
                          RadioSettingValueBoolean(is_dtmf))
        mem.extra.append(rs)
        tmpcomment += "DTMFdecode:"+(is_dtmf and "ON" or "off")+" "

        # Scrambler
        if _mem.scrambler & 0x0f < len(SCRAMBLER_LIST):
            enc = _mem.scrambler & 0x0f
        else:
            enc = 0

        rs = RadioSetting("scrambler", _("Scrambler"), RadioSettingValueList(
            SCRAMBLER_LIST, SCRAMBLER_LIST[enc]))
        mem.extra.append(rs)
        tmpcomment += "Scrambler:"+SCRAMBLER_LIST[enc]+" "

        rs = RadioSetting("scanlists", _("Scanlists"), RadioSettingValueList(
            SCANLIST_LIST, tmpscn))
        mem.extra.append(rs)

        return mem

    def set_settings(self, settings):
        _mem = self._memobj
        for element in settings:
            if not isinstance(element, RadioSetting):
                self.set_settings(element)
                continue

            # basic settings

            # call channel
            if element.get_name() == "call_channel":
                _mem.call_channel = int(element.value)-1

            # squelch
            if element.get_name() == "squelch":
                _mem.squelch = int(element.value)
            # TOT
            if element.get_name() == "tot":
                _mem.max_talk_time = int(element.value)

            # NOAA autoscan
            if element.get_name() == "noaa_autoscan":
                _mem.noaa_autoscan = element.value and 1 or 0

            # VOX switch
            if element.get_name() == "vox_switch":
                _mem.vox_switch = element.value and 1 or 0

            # vox level
            if element.get_name() == "vox_level":
                _mem.vox_level = int(element.value)-1

            # mic gain
            if element.get_name() == "mic_gain":
                _mem.mic_gain = int(element.value)

            # Channel display mode
            if element.get_name() == "channel_display_mode":
                _mem.channel_display_mode = CHANNELDISP_LIST.index(
                    str(element.value))

            # Crossband receiving/transmitting
            if element.get_name() == "crossband":
                _mem.crossband = CROSSBAND_LIST.index(str(element.value))

            # Battery Save
            if element.get_name() == "battery_save":
                _mem.battery_save = BATSAVE_LIST.index(str(element.value))
            # Dual Watch
            if element.get_name() == "dualwatch":
                _mem.dual_watch = DUALWATCH_LIST.index(str(element.value))

            # Backlight auto mode
            if element.get_name() == "backlight_auto_mode":
                _mem.backlight_auto_mode = \
                        BACKLIGHT_LIST.index(str(element.value))

            # Tail tone elimination
            if element.get_name() == "tail_note_elimination":
                _mem.tail_note_elimination = element.value and 1 or 0

            # VFO Open
            if element.get_name() == "vfo_open":
                _mem.vfo_open = element.value and 1 or 0

            # Beep control
            if element.get_name() == "beep_control":
                _mem.beep_control = element.value and 1 or 0

            # Scan resume mode
            if element.get_name() == "scan_resume_mode":
                _mem.scan_resume_mode = SCANRESUME_LIST.index(
                    str(element.value))

            # Keypad lock
            if element.get_name() == "key_lock":
                _mem.key_lock = element.value and 1 or 0

            # Auto keypad lock
            if element.get_name() == "auto_keypad_lock":
                _mem.auto_keypad_lock = element.value and 1 or 0

            # Power on display mode
            if element.get_name() == "welcome_mode":
                _mem.power_on_dispmode = WELCOME_LIST.index(str(element.value))

            # Keypad Tone
            if element.get_name() == "keypad_tone":
                _mem.keypad_tone = KEYPADTONE_LIST.index(str(element.value))

            # Language
            if element.get_name() == "language":
                _mem.language = LANGUAGE_LIST.index(str(element.value))

            # Alarm mode
            if element.get_name() == "alarm_mode":
                _mem.alarm_mode = ALARMMODE_LIST.index(str(element.value))

            # Reminding of end of talk
            if element.get_name() == "reminding_of_end_talk":
                _mem.reminding_of_end_talk = REMENDOFTALK_LIST.index(
                    str(element.value))

            # Repeater tail tone elimination
            if element.get_name() == "repeater_tail_elimination":
                _mem.repeater_tail_elimination = RTE_LIST.index(
                    str(element.value))

            # Logo string 1
            if element.get_name() == "logo1":
                b = convert_chinese_to_ascii_chars(element.value).encode('latin-1')
                self._welcome_logo[0] = b[0:18]

            # Logo string 2
            if element.get_name() == "logo2":
                b = convert_chinese_to_ascii_chars(element.value).encode('latin-1')
                self._welcome_logo[1] = b[0:18]

            # unlock settings

            # FLOCK
            if element.get_name() == "flock":
                _mem.lock.flock = FLOCK_LIST.index(str(element.value))

            # 350TX
            if element.get_name() == "tx350":
                _mem.lock.tx350 = element.value and 1 or 0

            # 200TX
            if element.get_name() == "tx200":
                _mem.lock.tx200 = element.value and 1 or 0

            # 500TX
            if element.get_name() == "tx500":
                _mem.lock.tx500 = element.value and 1 or 0

            # 350EN
            if element.get_name() == "en350":
                _mem.lock.en350 = element.value and 1 or 0

            # SCREN
            if element.get_name() == "enscramble":
                _mem.lock.enscramble = element.value and 1 or 0

            # KILLED
            if element.get_name() == "killed":
                _mem.lock.killed = element.value and 1 or 0

            # fm radio
            for i in range(1, 21):
                freqname = "FM_" + str(i)
                if element.get_name() == freqname:
                    val = str(element.value).strip()
                    try:
                        val2 = int(float(val)*10)
                    except Exception:
                        val2 = 0xffff

                    if val2 < FMMIN*10 or val2 > FMMAX*10:
                        val2 = 0xffff
#                        raise errors.InvalidValueError(
#                                "FM radio frequency should be a value "
#                                "in the range %.1f - %.1f" % (FMMIN , FMMAX))
                    _mem.fmfreq[i-1] = val2

            # dtmf settings
            if element.get_name() == "dtmf_side_tone":
                _mem.dtmf_settings.side_tone = \
                        element.value and 1 or 0

            if element.get_name() == "dtmf_separate_code":
                _mem.dtmf_settings.separate_code = str(element.value)

            if element.get_name() == "dtmf_group_call_code":
                _mem.dtmf_settings.group_call_code = element.value

            if element.get_name() == "dtmf_decode_response":
                _mem.dtmf_settings.decode_response = \
                        DTMF_DECODE_RESPONSE_LIST.index(str(element.value))

            if element.get_name() == "dtmf_auto_reset_time":
                _mem.dtmf_settings.auto_reset_time = \
                        int(int(element.value)/10)

            if element.get_name() == "dtmf_preload_time":
                _mem.dtmf_settings.preload_time = \
                        int(int(element.value)/10)

            if element.get_name() == "dtmf_first_code_persist_time":
                _mem.dtmf_settings.first_code_persist_time = \
                        int(int(element.value)/10)

            if element.get_name() == "dtmf_hash_persist_time":
                _mem.dtmf_settings.hash_persist_time = \
                        int(int(element.value)/10)

            if element.get_name() == "dtmf_code_persist_time":
                _mem.dtmf_settings.code_persist_time = \
                        int(int(element.value)/10)

            if element.get_name() == "dtmf_code_interval_time":
                _mem.dtmf_settings.code_interval_time = \
                        int(int(element.value)/10)

            if element.get_name() == "dtmf_permit_remote_kill":
                _mem.dtmf_settings.permit_remote_kill = \
                        element.value and 1 or 0

            if element.get_name() == "dtmf_dtmf_local_code":
                k = str(element.value).rstrip("\x20\xff\x00") + "\x00"*3
                _mem.dtmf_settings_numbers.dtmf_local_code = k[0:3]

            if element.get_name() == "dtmf_dtmf_up_code":
                k = str(element.value).strip("\x20\xff\x00") + "\x00"*16
                _mem.dtmf_settings_numbers.dtmf_up_code = k[0:16]

            if element.get_name() == "dtmf_dtmf_down_code":
                k = str(element.value).rstrip("\x20\xff\x00") + "\x00"*16
                _mem.dtmf_settings_numbers.dtmf_down_code = k[0:16]

            if element.get_name() == "dtmf_kill_code":
                k = str(element.value).strip("\x20\xff\x00") + "\x00"*5
                _mem.dtmf_settings_numbers.kill_code = k[0:5]

            if element.get_name() == "dtmf_revive_code":
                k = str(element.value).strip("\x20\xff\x00") + "\x00"*5
                _mem.dtmf_settings_numbers.revive_code = k[0:5]

            # dtmf contacts
            for i in range(1, 17):
                varname = "DTMF_" + str(i)
                if element.get_name() == varname:
                    k = str(element.value).rstrip("\x20\xff\x00") + "\x00"*8
                    _mem.dtmfcontact[i-1].name = k[0:8]

                varnumname = "DTMFNUM_" + str(i)
                if element.get_name() == varnumname:
                    k = str(element.value).rstrip("\x20\xff\x00") + "\xff"*3
                    _mem.dtmfcontact[i-1].number = k[0:3]

            # MDC 联系人
            element_name = element.get_name()
            valid_mdc = 0
            last_valid = 0
            for i in range(1, 23):
                mdc_id = "MDC_ID_" + str(i)
                mdc_name = "MDC_NAME_" + str(i)
                if element_name == mdc_id:
                    k = str(element.value).replace(' ', '').rjust(4, '0')
                    _mem.mdccontact1[i - 1].id = bytes.fromhex(k)[0:2]

                if element_name == mdc_name:
                    _mem.mdccontact1[i - 1].name = str(element.value)[0:14]

                is_not_empty = _mem.mdccontact1[i - 1].id.get_raw() != b'\x00' * 2 and _mem.mdccontact1[i - 1].name.get_raw() != b'\x20' * 20
                if is_not_empty and (last_valid == i - 1 or last_valid == 0):
                    valid_mdc = i
                    last_valid = i
            _mem.mdc_num = valid_mdc

            # scanlist stuff
            if element.get_name() == "scanlist_default":
                val = (int(element.value) == 2) and 1 or 0
                _mem.scanlist_default = val

            if element.get_name() == "scanlist1_priority_scan":
                _mem.scanlist1_priority_scan = \
                        element.value and 1 or 0

            if element.get_name() == "scanlist2_priority_scan":
                _mem.scanlist2_priority_scan = \
                        element.value and 1 or 0

            if element.get_name() == "scanlist1_priority_ch1" or \
                    element.get_name() == "scanlist1_priority_ch2" or \
                    element.get_name() == "scanlist2_priority_ch1" or \
                    element.get_name() == "scanlist2_priority_ch2":

                val = int(element.value)

                if val > 200 or val < 1:
                    val = 0xff
                else:
                    val -= 1

                if element.get_name() == "scanlist1_priority_ch1":
                    _mem.scanlist1_priority_ch1 = val
                if element.get_name() == "scanlist1_priority_ch2":
                    _mem.scanlist1_priority_ch2 = val
                if element.get_name() == "scanlist2_priority_ch1":
                    _mem.scanlist2_priority_ch1 = val
                if element.get_name() == "scanlist2_priority_ch2":
                    _mem.scanlist2_priority_ch2 = val

            if element.get_name() == "key1_shortpress_action":
                _mem.key1_shortpress_action = KEYACTIONS_LIST.index(
                        str(element.value))

            if element.get_name() == "key1_longpress_action":
                _mem.key1_longpress_action = KEYACTIONS_LIST.index(
                        str(element.value))

            if element.get_name() == "key2_shortpress_action":
                _mem.key2_shortpress_action = KEYACTIONS_LIST.index(
                        str(element.value))

            if element.get_name() == "key2_longpress_action":
                _mem.key2_longpress_action = KEYACTIONS_LIST.index(
                        str(element.value))

            if element.get_name() == "nolimits":
                LOG.warning("User expanded band limits")
                self._expanded_limits = bool(element.value)

    def get_settings(self):
        _mem = self._memobj
        basic = RadioSettingGroup("basic", "Basic Settings")
        keya = RadioSettingGroup("keya", "Programmable keys")
        dtmf = RadioSettingGroup("dtmf", "DTMF Settings")
        dtmfc = RadioSettingGroup("dtmfc", "DTMF Contacts")
        mdcc = RadioSettingGroup("mdcc", "MDC 联系人")
        scanl = RadioSettingGroup("scn", "Scan Lists")
        unlock = RadioSettingGroup("unlock", "Unlock Settings")
        fmradio = RadioSettingGroup("fmradio", _("FM Radio"))

        roinfo = RadioSettingGroup("roinfo", _("Driver information"))

        top = RadioSettings(
                basic, keya, dtmf, dtmfc, mdcc, scanl, unlock, fmradio, roinfo)

        # Programmable keys
        tmpval = int(_mem.key1_shortpress_action)
        if tmpval >= len(KEYACTIONS_LIST):
            tmpval = 0
        rs = RadioSetting("key1_shortpress_action", "Side key 1 short press",
                          RadioSettingValueList(
                              KEYACTIONS_LIST, KEYACTIONS_LIST[tmpval]))
        keya.append(rs)

        tmpval = int(_mem.key1_longpress_action)
        if tmpval >= len(KEYACTIONS_LIST):
            tmpval = 0
        rs = RadioSetting("key1_longpress_action", "Side key 1 long press",
                          RadioSettingValueList(
                              KEYACTIONS_LIST, KEYACTIONS_LIST[tmpval]))
        keya.append(rs)

        tmpval = int(_mem.key2_shortpress_action)
        if tmpval >= len(KEYACTIONS_LIST):
            tmpval = 0
        rs = RadioSetting("key2_shortpress_action", "Side key 2 short press",
                          RadioSettingValueList(
                              KEYACTIONS_LIST, KEYACTIONS_LIST[tmpval]))
        keya.append(rs)

        tmpval = int(_mem.key2_longpress_action)
        if tmpval >= len(KEYACTIONS_LIST):
            tmpval = 0
        rs = RadioSetting("key2_longpress_action", "Side key 2 long press",
                          RadioSettingValueList(
                              KEYACTIONS_LIST, KEYACTIONS_LIST[tmpval]))
        keya.append(rs)

        # DTMF settings
        tmppr = bool(_mem.dtmf_settings.side_tone > 0)
        rs = RadioSetting(
                "dtmf_side_tone",
                "DTMF Sidetone",
                RadioSettingValueBoolean(tmppr))
        dtmf.append(rs)

        tmpval = str(_mem.dtmf_settings.separate_code)
        if tmpval not in DTMF_CODE_CHARS:
            tmpval = '*'
        val = RadioSettingValueString(1, 1, tmpval)
        val.set_charset(DTMF_CODE_CHARS)
        rs = RadioSetting("dtmf_separate_code", "Separate Code", val)
        dtmf.append(rs)

        tmpval = str(_mem.dtmf_settings.group_call_code)
        if tmpval not in DTMF_CODE_CHARS:
            tmpval = '#'
        val = RadioSettingValueString(1, 1, tmpval)
        val.set_charset(DTMF_CODE_CHARS)
        rs = RadioSetting("dtmf_group_call_code", "Group Call Code", val)
        dtmf.append(rs)

        tmpval = _mem.dtmf_settings.decode_response
        if tmpval >= len(DTMF_DECODE_RESPONSE_LIST):
            tmpval = 0
        rs = RadioSetting("dtmf_decode_response", "Decode Response",
                          RadioSettingValueList(
                              DTMF_DECODE_RESPONSE_LIST,
                              DTMF_DECODE_RESPONSE_LIST[tmpval]))
        dtmf.append(rs)

        tmpval = _mem.dtmf_settings.auto_reset_time
        if tmpval > 60 or tmpval < 5:
            tmpval = 5
        rs = RadioSetting("dtmf_auto_reset_time",
                          "Auto reset time (s)",
                          RadioSettingValueInteger(5, 60, tmpval))
        dtmf.append(rs)

        tmpval = int(_mem.dtmf_settings.preload_time)
        if tmpval > 100 or tmpval < 3:
            tmpval = 30
        tmpval *= 10
        rs = RadioSetting("dtmf_preload_time",
                          "Pre-load time (ms)",
                          RadioSettingValueInteger(30, 1000, tmpval, 10))
        dtmf.append(rs)

        tmpval = int(_mem.dtmf_settings.first_code_persist_time)
        if tmpval > 100 or tmpval < 3:
            tmpval = 30
        tmpval *= 10
        rs = RadioSetting("dtmf_first_code_persist_time",
                          "First code persist time (ms)",
                          RadioSettingValueInteger(30, 1000, tmpval, 10))
        dtmf.append(rs)

        tmpval = int(_mem.dtmf_settings.hash_persist_time)
        if tmpval > 100 or tmpval < 3:
            tmpval = 30
        tmpval *= 10
        rs = RadioSetting("dtmf_hash_persist_time",
                          "#/* persist time (ms)",
                          RadioSettingValueInteger(30, 1000, tmpval, 10))
        dtmf.append(rs)

        tmpval = int(_mem.dtmf_settings.code_persist_time)
        if tmpval > 100 or tmpval < 3:
            tmpval = 30
        tmpval *= 10
        rs = RadioSetting("dtmf_code_persist_time",
                          "Code persist time (ms)",
                          RadioSettingValueInteger(30, 1000, tmpval, 10))
        dtmf.append(rs)

        tmpval = int(_mem.dtmf_settings.code_interval_time)
        if tmpval > 100 or tmpval < 3:
            tmpval = 30
        tmpval *= 10
        rs = RadioSetting("dtmf_code_interval_time",
                          "Code interval time (ms)",
                          RadioSettingValueInteger(30, 1000, tmpval, 10))
        dtmf.append(rs)

        tmpval = bool(_mem.dtmf_settings.permit_remote_kill > 0)
        rs = RadioSetting(
                "dtmf_permit_remote_kill",
                "Permit remote kill",
                RadioSettingValueBoolean(tmpval))
        dtmf.append(rs)

        tmpval = str(_mem.dtmf_settings_numbers.dtmf_local_code).upper().strip(
                "\x00\xff\x20")
        for i in tmpval:
            if i in DTMF_CHARS_ID:
                continue
            else:
                tmpval = "103"
                break
        val = RadioSettingValueString(3, 3, tmpval)
        val.set_charset(DTMF_CHARS_ID)
        rs = RadioSetting("dtmf_dtmf_local_code",
                          "Local code (3 chars 0-9 ABCD)", val)
        dtmf.append(rs)

        tmpval = str(_mem.dtmf_settings_numbers.dtmf_up_code).upper().strip(
                "\x00\xff\x20")
        for i in tmpval:
            if i in DTMF_CHARS_UPDOWN or i == "":
                continue
            else:
                tmpval = "123"
                break
        val = RadioSettingValueString(1, 16, tmpval)
        val.set_charset(DTMF_CHARS_UPDOWN)
        rs = RadioSetting("dtmf_dtmf_up_code",
                          "Up code (1-16 chars 0-9 ABCD*#)", val)
        dtmf.append(rs)

        tmpval = str(_mem.dtmf_settings_numbers.dtmf_down_code).upper().strip(
                "\x00\xff\x20")
        for i in tmpval:
            if i in DTMF_CHARS_UPDOWN:
                continue
            else:
                tmpval = "456"
                break
        val = RadioSettingValueString(1, 16, tmpval)
        val.set_charset(DTMF_CHARS_UPDOWN)
        rs = RadioSetting("dtmf_dtmf_down_code",
                          "Down code (1-16 chars 0-9 ABCD*#)", val)
        dtmf.append(rs)

        tmpval = str(_mem.dtmf_settings_numbers.kill_code).upper().strip(
                "\x00\xff\x20")
        for i in tmpval:
            if i in DTMF_CHARS_KILL:
                continue
            else:
                tmpval = "77777"
                break
        if not len(tmpval) == 5:
            tmpval = "77777"
        val = RadioSettingValueString(5, 5, tmpval)
        val.set_charset(DTMF_CHARS_KILL)
        rs = RadioSetting("dtmf_kill_code",
                          "Kill code (5 chars 0-9 ABCD)", val)
        dtmf.append(rs)

        tmpval = str(_mem.dtmf_settings_numbers.revive_code).upper().strip(
                "\x00\xff\x20")
        for i in tmpval:
            if i in DTMF_CHARS_KILL:
                continue
            else:
                tmpval = "88888"
                break
        if not len(tmpval) == 5:
            tmpval = "88888"
        val = RadioSettingValueString(5, 5, tmpval)
        val.set_charset(DTMF_CHARS_KILL)
        rs = RadioSetting("dtmf_revive_code",
                          "Revive code (5 chars 0-9 ABCD)", val)
        dtmf.append(rs)

        val = RadioSettingValueString(0, 80,
                                      "All DTMF Contacts are 3 codes "
                                      "(valid: 0-9 * # ABCD), "
                                      "or an empty string")
        val.set_mutable(False)
        rs = RadioSetting("dtmf_descr1", "DTMF Contacts", val)
        dtmfc.append(rs)

        for i in range(1, 17):
            varname = "DTMF_"+str(i)
            varnumname = "DTMFNUM_"+str(i)
            vardescr = "DTMF Contact "+str(i)+" name"
            varinumdescr = "DTMF Contact "+str(i)+" number"

            cntn = str(_mem.dtmfcontact[i-1].name).strip("\x20\x00\xff")
            cntnum = str(_mem.dtmfcontact[i-1].number).strip("\x20\x00\xff")

            val = RadioSettingValueString(0, 8, cntn)
            rs = RadioSetting(varname, vardescr, val)
            dtmfc.append(rs)

            val = RadioSettingValueString(0, 3, cntnum)
            val.set_charset(DTMF_CHARS)
            rs = RadioSetting(varnumname, varinumdescr, val)
            dtmfc.append(rs)

        # MDC 联系人
        val = RadioSettingValueString(0, 80,
                                      "MDC ID 应为 4位16进制数字 例如12AB, 联系人名称不能用中文, 请按顺序添加", charset=VALID_CHARACTERS)
        val.set_mutable(False)
        rs = RadioSetting("mdc_descr1", "MDC 联系人", val)
        mdcc.append(rs)

        for i in range(1, 23):
            mdc_id = "MDC_ID_" + str(i)
            mdc_name = "MDC_NAME_" + str(i)
            mdc_id_descr = "联系人" + str(i) + " | MDC ID"
            mdc_name_descr = "联系人" + str(i) + " | 名称"
            if i <= int(_mem.mdc_num):
                c_id = ''.join(['{:02X}'.format(int(byte)) for byte in _mem.mdccontact1[i - 1].id])
                c_name = str(_mem.mdccontact1[i - 1].name)

                val = RadioSettingValueString(0, 4, c_id, charset=' 0123456789ABCDEF')
                rs = RadioSetting(mdc_id, mdc_id_descr, val)
                mdcc.append(rs)

                try:
                    val = RadioSettingValueString(0, 14, c_name)
                except Exception:
                    val = RadioSettingValueString(0, 14, '')
                rs = RadioSetting(mdc_name, mdc_name_descr, val)
                mdcc.append(rs)
            else:
                val = RadioSettingValueString(0, 4, '', charset=' 0123456789ABCDEF')
                rs = RadioSetting(mdc_id, mdc_id_descr, val)
                mdcc.append(rs)

                val = RadioSettingValueString(0, 14, '')
                rs = RadioSetting(mdc_name, mdc_name_descr, val)
                mdcc.append(rs)

        # scanlists
        if _mem.scanlist_default == 1:
            tmpsc = 2
        else:
            tmpsc = 1
        rs = RadioSetting("scanlist_default",
                          "Default scanlist",
                          RadioSettingValueInteger(1, 2, tmpsc))
        scanl.append(rs)

        tmppr = bool((_mem.scanlist1_priority_scan & 1) > 0)
        rs = RadioSetting(
                "scanlist1_priority_scan",
                "Scanlist 1 priority channel scan",
                RadioSettingValueBoolean(tmppr))
        scanl.append(rs)

        tmpch = _mem.scanlist1_priority_ch1 + 1
        if tmpch > 200:
            tmpch = 0
        rs = RadioSetting("scanlist1_priority_ch1",
                          "Scanlist 1 priority channel 1 (0 - off)",
                          RadioSettingValueInteger(0, 200, tmpch))
        scanl.append(rs)

        tmpch = _mem.scanlist1_priority_ch2 + 1
        if tmpch > 200:
            tmpch = 0
        rs = RadioSetting("scanlist1_priority_ch2",
                          "Scanlist 1 priority channel 2 (0 - off)",
                          RadioSettingValueInteger(0, 200, tmpch))
        scanl.append(rs)

        tmppr = bool((_mem.scanlist2_priority_scan & 1) > 0)
        rs = RadioSetting(
                "scanlist2_priority_scan",
                "Scanlist 2 priority channel scan",
                RadioSettingValueBoolean(tmppr))
        scanl.append(rs)

        tmpch = _mem.scanlist2_priority_ch1 + 1
        if tmpch > 200:
            tmpch = 0
        rs = RadioSetting("scanlist2_priority_ch1",
                          "Scanlist 2 priority channel 1 (0 - off)",
                          RadioSettingValueInteger(0, 200, tmpch))
        scanl.append(rs)

        tmpch = _mem.scanlist2_priority_ch2 + 1
        if tmpch > 200:
            tmpch = 0
        rs = RadioSetting("scanlist2_priority_ch2",
                          "Scanlist 2 priority channel 2 (0 - off)",
                          RadioSettingValueInteger(0, 200, tmpch))
        scanl.append(rs)

        # basic settings

        # call channel
        tmpc = _mem.call_channel+1
        if tmpc > 200:
            tmpc = 1
        rs = RadioSetting("call_channel", "One key call channel",
                          RadioSettingValueInteger(1, 200, tmpc))
        basic.append(rs)

        # squelch
        tmpsq = _mem.squelch
        if tmpsq > 9:
            tmpsq = 1
        rs = RadioSetting("squelch", "Squelch",
                          RadioSettingValueInteger(0, 9, tmpsq))
        basic.append(rs)

        # TOT
        tmptot = _mem.max_talk_time
        if tmptot > 10:
            tmptot = 10
        rs = RadioSetting(
                "tot",
                "Max talk time [min]",
                RadioSettingValueInteger(0, 10, tmptot))
        basic.append(rs)

        # NOAA autoscan
        rs = RadioSetting(
                "noaa_autoscan",
                "NOAA Autoscan", RadioSettingValueBoolean(
                    bool(_mem.noaa_autoscan > 0)))
        basic.append(rs)

        # VOX switch
        rs = RadioSetting(
                "vox_switch",
                "VOX enabled", RadioSettingValueBoolean(
                    bool(_mem.vox_switch > 0)))
        basic.append(rs)

        # VOX Level
        tmpvox = _mem.vox_level+1
        if tmpvox > 10:
            tmpvox = 10
        rs = RadioSetting("vox_level", "VOX Level",
                          RadioSettingValueInteger(1, 10, tmpvox))
        basic.append(rs)

        # Mic gain
        tmpmicgain = _mem.mic_gain
        if tmpmicgain > 4:
            tmpmicgain = 4
        rs = RadioSetting("mic_gain", "Mic Gain",
                          RadioSettingValueInteger(0, 4, tmpmicgain))
        basic.append(rs)

        # Channel display mode
        tmpchdispmode = _mem.channel_display_mode
        if tmpchdispmode >= len(CHANNELDISP_LIST):
            tmpchdispmode = 0
        rs = RadioSetting(
                "channel_display_mode",
                "Channel display mode",
                RadioSettingValueList(
                    CHANNELDISP_LIST,
                    CHANNELDISP_LIST[tmpchdispmode]))
        basic.append(rs)

        # Crossband receiving/transmitting
        tmpcross = _mem.crossband
        if tmpcross >= len(CROSSBAND_LIST):
            tmpcross = 0
        rs = RadioSetting(
                "crossband",
                "Cross-band receiving/transmitting",
                RadioSettingValueList(
                    CROSSBAND_LIST,
                    CROSSBAND_LIST[tmpcross]))
        basic.append(rs)

        # Battery save
        tmpbatsave = _mem.battery_save
        if tmpbatsave >= len(BATSAVE_LIST):
            tmpbatsave = BATSAVE_LIST.index("1:4")
        rs = RadioSetting(
                "battery_save",
                "Battery Save",
                RadioSettingValueList(
                    BATSAVE_LIST,
                    BATSAVE_LIST[tmpbatsave]))
        basic.append(rs)

        # Dual watch
        tmpdual = _mem.dual_watch
        if tmpdual >= len(DUALWATCH_LIST):
            tmpdual = 0
        rs = RadioSetting("dualwatch", "Dual Watch", RadioSettingValueList(
            DUALWATCH_LIST, DUALWATCH_LIST[tmpdual]))
        basic.append(rs)

        # Backlight auto mode
        tmpback = _mem.backlight_auto_mode
        if tmpback >= len(BACKLIGHT_LIST):
            tmpback = 0
        rs = RadioSetting("backlight_auto_mode",
                          "Backlight auto mode",
                          RadioSettingValueList(
                              BACKLIGHT_LIST,
                              BACKLIGHT_LIST[tmpback]))
        basic.append(rs)

        # Tail tone elimination
        rs = RadioSetting(
                "tail_note_elimination",
                "Tail tone elimination",
                RadioSettingValueBoolean(
                    bool(_mem.tail_note_elimination > 0)))
        basic.append(rs)

        # VFO open
        rs = RadioSetting("vfo_open", "VFO open",
                          RadioSettingValueBoolean(bool(_mem.vfo_open > 0)))
        basic.append(rs)

        # Beep control
        rs = RadioSetting(
                "beep_control",
                "Beep control",
                RadioSettingValueBoolean(bool(_mem.beep_control > 0)))
        basic.append(rs)

        # Scan resume mode
        tmpscanres = _mem.scan_resume_mode
        if tmpscanres >= len(SCANRESUME_LIST):
            tmpscanres = 0
        rs = RadioSetting(
                "scan_resume_mode",
                "Scan resume mode",
                RadioSettingValueList(
                    SCANRESUME_LIST,
                    SCANRESUME_LIST[tmpscanres]))
        basic.append(rs)

        # Keypad locked
        rs = RadioSetting(
                "key_lock",
                "Keypad lock",
                RadioSettingValueBoolean(bool(_mem.key_lock > 0)))
        basic.append(rs)

        # Auto keypad lock
        rs = RadioSetting(
                "auto_keypad_lock",
                "Auto keypad lock",
                RadioSettingValueBoolean(bool(_mem.auto_keypad_lock > 0)))
        basic.append(rs)

        # Power on display mode
        tmpdispmode = _mem.power_on_dispmode
        if tmpdispmode >= len(WELCOME_LIST):
            tmpdispmode = 0
        rs = RadioSetting(
                "welcome_mode",
                "Power on display mode",
                RadioSettingValueList(
                    WELCOME_LIST,
                    WELCOME_LIST[tmpdispmode]))
        basic.append(rs)

        # Keypad Tone
        tmpkeypadtone = _mem.keypad_tone
        if tmpkeypadtone >= len(KEYPADTONE_LIST):
            tmpkeypadtone = 0
        rs = RadioSetting("keypad_tone", "Keypad tone", RadioSettingValueList(
            KEYPADTONE_LIST, KEYPADTONE_LIST[tmpkeypadtone]))
        basic.append(rs)

        # Language
        tmplanguage = _mem.language
        if tmplanguage >= len(LANGUAGE_LIST):
            tmplanguage = 0
        rs = RadioSetting("language", "Language", RadioSettingValueList(
            LANGUAGE_LIST, LANGUAGE_LIST[tmplanguage]))
        basic.append(rs)

        # Alarm mode
        tmpalarmmode = _mem.alarm_mode
        if tmpalarmmode >= len(ALARMMODE_LIST):
            tmpalarmmode = 0
        rs = RadioSetting("alarm_mode", "Alarm mode", RadioSettingValueList(
            ALARMMODE_LIST, ALARMMODE_LIST[tmpalarmmode]))
        basic.append(rs)

        # Reminding of end of talk
        tmpalarmmode = _mem.reminding_of_end_talk
        if tmpalarmmode >= len(REMENDOFTALK_LIST):
            tmpalarmmode = 0
        rs = RadioSetting(
                "reminding_of_end_talk",
                "Reminding of end of talk",
                RadioSettingValueList(
                    REMENDOFTALK_LIST,
                    REMENDOFTALK_LIST[tmpalarmmode]))
        basic.append(rs)

        # Repeater tail tone elimination
        tmprte = _mem.repeater_tail_elimination
        if tmprte >= len(RTE_LIST):
            tmprte = 0
        rs = RadioSetting(
                "repeater_tail_elimination",
                "Repeater tail tone elimination",
                RadioSettingValueList(RTE_LIST, RTE_LIST[tmprte]))
        basic.append(rs)

        # Logo string 1
        logo1 = convert_bytes_to_chinese(self._welcome_logo[0])
        rs = RadioSetting("logo1", _("欢迎字符1 (18字符)"),
                          RadioSettingChineseValueString(0, 18, logo1, False, VALID_CHARACTERS))
        basic.append(rs)

        # Logo string 2
        logo2 = convert_bytes_to_chinese(self._welcome_logo[1])
        rs = RadioSetting("logo2", _("欢迎字符2 (18字符)"),
                          RadioSettingChineseValueString(0, 18, logo2, False, VALID_CHARACTERS))
        basic.append(rs)

        # FM radio
        for i in range(1, 21):
            freqname = "FM_"+str(i)
            fmfreq = _mem.fmfreq[i-1]/10.0
            if fmfreq < FMMIN or fmfreq > FMMAX:
                rs = RadioSetting(freqname, freqname,
                                  RadioSettingValueString(0, 5, ""))
            else:
                rs = RadioSetting(freqname, freqname,
                                  RadioSettingValueString(0, 5, str(fmfreq)))

            fmradio.append(rs)

        # unlock settings

        # F-LOCK
        tmpflock = _mem.lock.flock
        if tmpflock >= len(FLOCK_LIST):
            tmpflock = 0
        rs = RadioSetting(
            "flock", "F-LOCK",
            RadioSettingValueList(FLOCK_LIST, FLOCK_LIST[tmpflock]))
        unlock.append(rs)

        # 350TX
        rs = RadioSetting("tx350", "350TX - unlock 350-400 MHz TX",
                          RadioSettingValueBoolean(
                              bool(_mem.lock.tx350 > 0)))
        unlock.append(rs)

        # Killed
        rs = RadioSetting("Killed", "KILLED Device was disabled (via DTMF)",
                          RadioSettingValueBoolean(
                              bool(_mem.lock.killed > 0)))
        unlock.append(rs)

        # 200TX
        rs = RadioSetting("tx200", "200TX - unlock 174-350 MHz TX",
                          RadioSettingValueBoolean(
                              bool(_mem.lock.tx200 > 0)))
        unlock.append(rs)

        # 500TX
        rs = RadioSetting("tx500", "500TX - unlock 500-600 MHz TX",
                          RadioSettingValueBoolean(
                              bool(_mem.lock.tx500 > 0)))
        unlock.append(rs)

        # 350EN
        rs = RadioSetting("en350", "350EN - unlock 350-400 MHz RX",
                          RadioSettingValueBoolean(
                              bool(_mem.lock.en350 > 0)))
        unlock.append(rs)

        # SCREEN
        rs = RadioSetting("scrambler", "SCREN - scrambler enable",
                          RadioSettingValueBoolean(
                              bool(_mem.lock.enscramble > 0)))
        unlock.append(rs)

        # readonly info
        # Firmware
        if self.FIRMWARE_VERSION == "":
            firmware = "To get the firmware version please download"
            "the image from the radio first"
        else:
            firmware = self.FIRMWARE_VERSION

        val = RadioSettingValueString(0, 128, firmware)
        val.set_mutable(False)
        rs = RadioSetting("fw_ver", "Firmware Version", val)
        roinfo.append(rs)

        # No limits version for hacked firmware
        val = RadioSettingValueBoolean(self._expanded_limits)
        rs = RadioSetting("nolimits", "Limits disabled for modified firmware",
                          val)
        rs.set_warning(_(
            'This should only be enabled if you are using modified firmware '
            'that supports wider frequency coverage. Enabling this will cause '
            'CHIRP not to enforce OEM restrictions and may lead to undefined '
            'or unregulated behavior. Use at your own risk!'),
            safe_value=False)
        roinfo.append(rs)

        return top

    # Store details about a high-level memory to the memory map
    # This is called when a user edits a memory in the UI
    def set_memory(self, mem):
        number = mem.number-1

        # Get a low-level memory object mapped to the image
        _mem = self._memobj.channel[number]
        _mem4 = self._memobj
        # empty memory
        if mem.empty:
            _mem.set_raw("\xFF" * 16)
            if number < 200:
                _mem2 = self._memobj.channelname[number]
                _mem2.set_raw("\xFF" * 16)
                _mem4.channel_attributes[number].is_scanlist1 = 0
                _mem4.channel_attributes[number].is_scanlist2 = 0
                _mem4.channel_attributes[number].unknown1 = 0
                _mem4.channel_attributes[number].unknown2 = 0
                _mem4.channel_attributes[number].is_free = 1
                _mem4.channel_attributes[number].band = 0x7
            return mem

        # clean the channel memory, restore some bits if it was used before
        if _mem.get_raw(asbytes=False)[0] == "\xff":
            # this was an empty memory
            _mem.set_raw("\x00" * 16)
        else:
            # this memory wasn't empty, save some bits that we don't know the
            # meaning of, or that we don't support yet
            prev_0a = _mem.get_raw()[0x0a] & SAVE_MASK_0A
            prev_0b = _mem.get_raw()[0x0b] & SAVE_MASK_0B
            prev_0c = _mem.get_raw()[0x0c] & SAVE_MASK_0C
            prev_0d = _mem.get_raw()[0x0d] & SAVE_MASK_0D
            prev_0e = _mem.get_raw()[0x0e] & SAVE_MASK_0E
            prev_0f = _mem.get_raw()[0x0f] & SAVE_MASK_0F
            _mem.set_raw("\x00" * 10 +
                         chr(prev_0a) + chr(prev_0b) + chr(prev_0c) +
                         chr(prev_0d) + chr(prev_0e) + chr(prev_0f))

        if number < 200:
            _mem4.channel_attributes[number].is_scanlist1 = 0
            _mem4.channel_attributes[number].is_scanlist2 = 0
            _mem4.channel_attributes[number].unknown1 = 0
            _mem4.channel_attributes[number].unknown2 = 0
            _mem4.channel_attributes[number].is_free = 1
            _mem4.channel_attributes[number].band = 0x7

        # find band
        band = _find_band(self, mem.freq)

        # mode
        if mem.mode == "NFM":
            _mem.bandwidth = 1
            _mem.enable_am = 0
        elif mem.mode == "FM":
            _mem.bandwidth = 0
            _mem.enable_am = 0
        elif mem.mode == "NAM":
            _mem.bandwidth = 1
            _mem.enable_am = 1
        elif mem.mode == "AM":
            _mem.bandwidth = 0
            _mem.enable_am = 1

        # frequency/offset
        _mem.freq = mem.freq/10
        _mem.offset = mem.offset/10

        if mem.duplex == "":
            _mem.offset = 0
            _mem.shift = 0
        elif mem.duplex == '-':
            _mem.shift = FLAGS1_OFFSET_MINUS
        elif mem.duplex == '+':
            _mem.shift = FLAGS1_OFFSET_PLUS
        elif mem.duplex == 'off':
            # we fake tx disable by setting the tx freq to 0 MHz
            _mem.shift = FLAGS1_OFFSET_MINUS
            _mem.offset = _mem.freq

        # set band
        if number < 200:
            _mem4.channel_attributes[number].is_free = 0
            _mem4.channel_attributes[number].band = band

        # channels >200 are the 14 VFO chanells and don't have names
        if number < 200:
            _mem2 = self._memobj.channelname[number]
            text = convert_chinese_to_ascii_chars(mem.name)
            if len(text) < 16:
                text += "\x00" * (16-len(text))
            elif len(text) >= 16:
                text = text[:16]
            _mem2.name = text  # Store the alpha tag

        # tone data
        self._set_tone(mem, _mem)

        # step
        _mem.step = STEPS.index(mem.tuning_step)

        # tx power
        if str(mem.power) == str(UVK5_POWER_LEVELS[2]):
            _mem.txpower = POWER_HIGH
        elif str(mem.power) == str(UVK5_POWER_LEVELS[1]):
            _mem.txpower = POWER_MEDIUM
        else:
            _mem.txpower = POWER_LOW

        for setting in mem.extra:
            sname = setting.get_name()
            svalue = setting.value.get_value()

            if sname == "bclo":
                _mem.bclo = svalue and 1 or 0

            if sname == "pttid":
                _mem.dtmf_pttid = PTTID_LIST.index(svalue)

            if sname == "frev":
                _mem.freq_reverse = svalue and 1 or 0

            if sname == "dtmfdecode":
                _mem.dtmf_decode = svalue and 1 or 0

            if sname == "scrambler":
                _mem.scrambler = (
                    _mem.scrambler & 0xf0) | SCRAMBLER_LIST.index(svalue)

            if number < 200 and sname == "scanlists":
                if svalue == "1":
                    _mem4.channel_attributes[number].is_scanlist1 = 1
                    _mem4.channel_attributes[number].is_scanlist2 = 0
                elif svalue == "2":
                    _mem4.channel_attributes[number].is_scanlist1 = 0
                    _mem4.channel_attributes[number].is_scanlist2 = 1
                elif svalue == "1+2":
                    _mem4.channel_attributes[number].is_scanlist1 = 1
                    _mem4.channel_attributes[number].is_scanlist2 = 1
                else:
                    _mem4.channel_attributes[number].is_scanlist1 = 0
                    _mem4.channel_attributes[number].is_scanlist2 = 0

        return mem

    def get_memobj(self):
        return self._memobj